<?php
?>
<h3> ΠΑΙΔΑΓΩΓΙΚΗ ΟΜΑΔΑ (ΔΙΔΑΣΚΟΝΤΕΣ) ΚΑΙ ΠΡΟΓΡΑΜΜΑ ΕΠΙΣΚΕΨΕΩΝ</h3> 
<?php
$dd=date('D', strtotime($dt));
$tm=array();
$dayf=array("Mon","Tue","Wed","Thu","Fri");
$daymap = array('Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή');
$res1=mysqli_query($con,"SELECT * FROM stutimetable WHERE id = (SELECT id+1 FROM stutimetable WHERE mitroo='$mitroo' or mitroo='$mitr')");
$rows1 = mysqli_fetch_array($res1); 
$ind=1;	
for ($x=1;$x<=5;$x++)
{
	for ($per=1;$per<=$gym;$per++)
	{
			$day1=$dayf[$x].$per;
			$srow= $rows1["$day1"];
			$sall=explode("/",$srow);
			$less = $sall[1];
			$teach= $sall[2];
			$tm[$ind]= $less."/".$teach;
			$ind++;
	}
}

$tm1 = array_values(array_unique($tm));
$tot = count($tm1);
$tot--;
$unmath1=$unteach1=array();
$k=1;
for ($i=0;$i<=$tot;$i++)
{
	$ar = explode("/",$tm1[$i]);
	if ($ar[0]<>"")
	{
		$unteach1[$k]=$ar[1];$unmath1[$k]=$ar[0];
		$k++;
	}
}
$k--;

echo "<table  class='myTable' >
<tr style='border:1px solid black' bgcolor='#FFAF80'  >
<th>Α/Α</th>
<th>ΜΑΘΗΜΑ</th>
<th>ΔΙΔΑΣΚΩΝ</th>
<th colspan='2'>ΗΜΕΡΑ ΚΑΙ ΠΕΡΙΟΔΟΣ ΕΠΙΣΚΕΨΕΩΝ</th>
</tr>";
for ($i=1;$i<=$k;$i++)
{
	echo "<tr>";
	echo "<td>".$i."</td>";
	echo "<td>" .$unmath1[$i]. "</td>";
	$sqlt=mysqli_query($con,"SELECT Name FROM teachers WHERE PMP='$unteach1[$i]'");
	$rowt=mysqli_fetch_array($sqlt);
	$nm=$rowt['Name'];
	$sqlt=mysqli_query($con,"SELECT * FROM episkepsis WHERE pmp='$unteach1[$i]'");
	$rowt=mysqli_fetch_array($sqlt);
	echo "<td>" . $nm. "</td>";
	echo "<td>" . $daymap[array_search($rowt['day'], $dayf)]. "</td>";
	echo "<td>" . $rowt['period']. "</td>";
	echo "</tr>";
}
echo "</table>";