<?php
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</script>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:5px;font-size:14px; }
<p style="font-size:14px;"></p>
</style>


</head>

<body>
<?php

require("dbconnect.php");
$sx=explode("/",$_GET['synx']);
$syndid=$sx[0];
$synd=$sx[1];

echo "<br>";
echo "<font face='arial' size='4pt'>TMHMA / ΣΥΝΔΙΔΑΣΚΑΛΙΑ : $synd </font> "; 
echo "<br>";

$result = mysqli_query($con,"SELECT  s.mitroo,a.eponimo,a.onoma,a.tmima,c.synd FROM syndidaskalies as s,allstudentinfo as a, syndcodes as c 
WHERE s.syndid = '$syndid' AND s.mitroo=a.mitroo and s.syndid=c.syndid ORDER BY a.eponimo,a.onoma");
	$crow1=mysqli_num_rows($result);
	$cr=0;
	while($row=mysqli_fetch_array($result))
	{	
		$cr++;
		$mt[$cr]=$row['mitroo'];
	    $epo[$cr]=$row['eponimo']." ".$row['onoma'];	
		$tmim[$cr]=$row['tmima'];
		$epilogi[$cr]='checked';
		$synd=$row['synd'];
	}
if ($synd=='Αλλόγλωσσοι')
{
$result = mysqli_query($con,"SELECT  mitroo,eponimo,onoma,tmima FROM allstudentinfo  ORDER BY tmima,eponimo,onoma ASC");	
}	
elseif (mb_substr($synd, 0, 2, 'utf-8')=='Στ') 
{
   $ftaxi=mb_substr($synd, 2, 1, 'utf-8');	
   $result = mysqli_query($con,"SELECT  mitroo,eponimo,onoma,tmima FROM allstudentinfo WHERE tmima like '$ftaxi%' ORDER BY tmima,eponimo,onoma ASC");	
}	
elseif ( in_array(mb_substr($synd, 0, 1, 'utf-8'),array('Α','Β','Γ')))  
{
   $ftaxi=mb_substr($synd, 0, 1, 'utf-8');
   $result = mysqli_query($con,"SELECT  mitroo,eponimo,onoma,tmima FROM allstudentinfo WHERE tmima like '$ftaxi%' ORDER BY tmima,eponimo,onoma ASC");	
}
else
{
 $result = mysqli_query($con,"SELECT  mitroo,eponimo,onoma,tmima FROM allstudentinfo  ORDER BY tmima,eponimo,onoma ASC"); 	
}		
//$result = mysqli_query($con,"SELECT  mitroo,eponimo,onoma,tmima FROM allstudentinfo WHERE tmima like '$ftaxi%' ORDER BY tmima,eponimo,onoma ASC");	

$cnt=mysqli_num_rows($result);

if ($cnt > 0)
{
  while($row=mysqli_fetch_array($result))
	{	
		$cr++;
		$mt[$cr]=$row['mitroo'];
	    $epo[$cr]=$row['eponimo']." ".$row['onoma'];	
		$tmim[$cr]=$row['tmima'];
		$epilogi[$cr]='unchecked';
		
	}
?>
<form method="POST" name = "al2" action="allagisynd2.php" >
 
<?php
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:14px'  >
<tr>
<th>α/α</th>
<th>Α.Μ</th>
<th>Τμήμα</th>
<th>Όνοματεπώνυμο</th>
<th>Επιλογή</th>
</tr>";

//$tot=$crow1+$cnt;
for($i=1;$i<=$cr;$i++)
 {
	 echo "<tr>";
	 echo "<td>" .$i;
	 echo "<td>". "<input type='text' name='mt[]' value='$mt[$i]' size='3' >" . "</td>";
	 echo "<td>". "<input type='text' name='tmim' value='$tmim[$i]' size='3' >" . "</td>";
	 echo "<td>". "<input type='text' name='epo[]' value='$epo[$i]' size='40' >" . "</td>"; 
	 echo "<td>". "<input type='checkbox' name='att[]' value='$mt[$i]'  $epilogi[$i] >" ."</td>";
	 echo  "<input type='hidden' name='syndid' value='$syndid'  >" ;
	 echo "</tr>";
}
echo "</table>";

?>
<button type="submit"name="sadd">Καταχώρηση</button>
<button type="submit"name="sdel">Διαγραφή</button>

</form>
<?php
}
?>		
</body>
</html>