<?php
include "scrinit.php";
include $menu;
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:11px; }
<p style="font-size:09px;"></p>
</style>
<?php
require "dbconnect.php";
$usr=$_SESSION['usr'];
$date=$_SESSION['dt'];
$eid=" ";
if (isset($_POST['eidik']))
{
	$eid=$_POST['eidikotita'];
}
echo "<p class='p1'>"."ΕΠΙΛΟΓΗ ΕΙΔΙΚΟΤΗΤΑΣ:"."</p> ";
$sql = mysqli_query($con,"SELECT * FROM vdsint WHERE pmp='$usr' " );	
?>
<form  method="post"  > 
<?php

$c=mysqli_num_rows($sql);
echo "<select name='eidikotita'>";
while ($row = mysqli_fetch_array($sql)) 
{
   	$e=$row['mathima'];
	?><option value =<?php echo $e; ?> <?php if($e == $eid) echo "selected";?> > <?php echo $row['mathima']; ?></option><?php
}
echo "</select>";
?>	
<input type="Submit" name="eidik" value="ΕΠΙΛΟΓΗ ΕΙΔΙΚΟΤΗΤΑΣ" >

</form>	

<?php

if (isset($_POST['eidik'])) 
{
$dat=$_SESSION['dt'];
$eid=trim($_POST['eidikotita']);
$_SERVER['PHP_SELF'];

echo "<p class='p1'>"."ΣΥΝΤΟΝΙΣΜΟΙ ΕΙΔΙΚΟΤΗΤΑΣ:"."</p> ";
echo "<table class='myTable3' >
<tr style='border:1px solid black;font-size:12px'  >
<tr>
<th>Κωδικός</th>
<th>Ημερομ.</th>
<th>Περ.</th>
<th>Απόντες</th>
<th>Λέξεις κλειδια</th>
</tr>";	

///// get next autoinncrement
$sqlx = "select max(code) as mc from sintonismos";
$resultx=$con->query($sqlx);
$rowx = $resultx->fetch_assoc();
$coden= $rowx['mc']+1;

$sql = mysqli_query($con,"SELECT * FROM sintonismos WHERE eidikotita='$eid'  group by code order by code " );	

while ($row = mysqli_fetch_array($sql)) 
{
	echo "<tr>";
	$pass=$row['code']."/".$eid;
	echo "<td>" ."<a href=\"themasint.php?data=".$pass."\">".$row['code']. "</a>". "</td>";
	echo "<td>". $row['date'] . "</td>";
	echo "<td>". $row['per'] . "</td>";
	$aponx=unserialize($row['apon']);
	$c=count($aponx);$apond="";
	for ($i=0;$i<$c;$i++)
		{
		    $r=mysqli_query($con,"select Name from teachers where PMP='$aponx[$i]'");
			$rowy=mysqli_fetch_array($r);
			$apond=$apond.$rowy['Name'].",  ";
		}
	echo "<td>".trim($apond,', ')."</td>";
	echo "<td>".$row['keywords']."</td>";
	echo "</tr>";
}
echo "<tr>";
echo "<td>" .$coden. "</td>";
$pass=$coden."/".$eid;
echo "<td colspan='4'>" . "<a href=\"themasint.php?data=".$pass."\">"."Καταχώρηση Νέου Συντονισμού". "</a>". "</td>";

}
?>
</body>
</html>