<?php
include "scrinit.php";
include $menu;
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>

</head>
<h3>ΕΞΟΔΟΣ ΓΙΑ ΑΠΟΧΩΡΗΤΗΡΙΟ </h3>
<body>
<?php
require("dbconnect.php");
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];

$sql = mysqli_query($con,"SELECT w.*,a.tmima,a.onoma,a.eponimo from wc as w,allstudentinfo as a where a.mitroo=w.mitroo order by a.tmima,w.mitroo,w.date,w.period " );
$c=mysqli_num_rows($sql);
if ($c >0)
{
echo "<table class='myTable' >
<tr style='border:1px solid black' >
<tr>
<th>Αρ.M</th>
<th>Τμήμα</th>
<th>Όνομα</th>
<th>Ημερομηνία</th>
<th>Διδάσκων</th>
<th>Μάθημα</th>
";

for ($i=1;$i<=$gym;$i++)
{
	$titep="Περ".$i;
	echo "<th>".$titep."</th>";
}
echo "</tr>";
while($row = mysqli_fetch_array($sql)) 
{
	$mitr=$row['mitroo'];
	$per=$row['period'];
	$date=$row['date'];
	$teacher=$row['teacher'];
	$less=$row['lesson'];
	$name=$row['eponimo']." ".$row['onoma'];
	$tmima=$row['tmima'];
	$q=mysqli_query($con,"select Name from teachers where PMP='$teacher'");
	$rowq=mysqli_fetch_array($q);
	$tname=$rowq['Name'];  
	echo "<tr>";
	if ($mitr <> $oldm)
	{
		echo "<td>". $mitr. "</td>";
		echo "<td>". $tmima . "</td>";
		echo "<td>". $name. "</td>";
	}
	else
	{
		echo "<td>". "". "</td>";
		echo "<td>". "" . "</td>";
		echo "<td>". "". "</td>";
	}
	echo "<td>". date('d-m-Y', strtotime($date)). "</td>";
	echo "<td>". $tname. "</td>";
	echo "<td>". $less. "</td>";
	for ($i=1;$i<=$gym;$i++)
	{
		if ($per==$i)
		{
			echo "<td>".'*'."</td>";
		}
		else
		{
			echo "<td>".' '."</td>";
		}
	}
	echo "</tr>";
	$oldm=$mitr;
}

echo "</table>";	 
}
else
{
	echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΑΝΑΦΟΡΕΣ ΓΙΑ WC";
}
?>
<br >
<br >
<br >
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>