<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:4px;font-size:14pt; }
<p style="font-size:14px;"></p>
</style>
</head>

<body>

<h3>ΚΩΔΙΚΟΙ ΜΑΘΗΜΑΤΩΝ ΓΙΑ ΤΟ TEAMS</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')");
$rows1 = mysqli_fetch_array($res1); 

$res1=mysqli_query($con,"SELECT * FROM stutimetable WHERE mitroo='$mitroo'");
$rows1 = mysqli_fetch_array($res1); 
$res2=mysqli_query($con,"SELECT * FROM stutimetable WHERE id = (SELECT id+1 FROM stutimetable WHERE mitroo='$mitroo')");
$rows2 = mysqli_fetch_array($res2); 

$ind=0;	
for ($x=1;$x<=5;$x++)
{
	for ($per=1;$per<=$gym;$per++)
	{
			$ind++;
			$day1=$dayf[$x].$per;
			$tmima= $rows1["$day1"];
			$srow2= $rows2["$day1"];
			$sall=explode("/",$srow2);
			$less = trim($sall[1]);
			$teach= $sall[2];
			$tm1[$ind]=$tmima."/".$less."/".$teach;
			$tm2[$ind]=$teach;
	}
}
$tm1 = array_values(array_unique($tm1));
$tot = count($tm1);
$tot--;$tot--;

for ($i=0;$i<=$tot;$i++)
{
	$ar = explode("/",$tm1[$i]);
	$tc[$i]=$ar[2];
	$tm3[$i]=$ar[0]."/".$ar[1];
	//echo $tc[$i].$tm3[$i];
	
}

echo "<table  class='myTable' >
<tr style='border:1px solid black;padding:4px;font-size:14px' bgcolor='#FFAF80'  >
	<th>Α/Α</th>
	<th>ΤΜΗΜΑ/ΜΑΘΗΜΑ</th>
	<th>ΚΩΔΙΚΟΣ ΤΕΑΜΣ</th>
	</tr>";
$i=0;
foreach ($tm3 as $m)
{ 		  
	
	$t=mysqli_query($con,"select code from teams where pmp='$tc[$i]' and mathima='".trim($m)."'");
	$row=mysqli_fetch_array($t);
	$tm=$row['code'];
	echo "<tr>";
	echo "<td>". $i."</td>";
	echo "<td>".$m."</td>";
	//echo "<td>".$tc[$i]."</td>";
	echo "<td>".$tm."</td>";
	echo "</tr>";
	$i++;
}
echo "</table>";

	