<?php
include "scrinit.php";
include "logo.php";
?>
<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:2px;font-size:14pt; }
<p style="font-size:14px;"></p>
</style>
</head>

<body>
<h3> ΕΒΔΟΜΑΔΙΑΙΟ ΠΡΟΓΡΑΜΜΑ ΜΑΘΗΤΗ/ΤΡΙΑΣ </h3>
<?php
require "dbconnect.php";
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];

$dd=date('D', strtotime($dt));
if (isset($_POST['nameid']))
{
  $mitroo=$_POST['nameid'];
}
else 
{
  $mitroo=$_SESSION['usr'];
}
	
	
	$result = mysqli_query($con,"SELECT mitroo,eponimo,onoma,tmima  FROM allstudentinfo WHERE mitroo='$mitroo'");
    $row = mysqli_fetch_array($result);
	$nm=$row['eponimo']." ".$row['onoma'];
	$tmima=$row['tmima'];
	echo  $nm. " , ( ".$tmima." )" ;
	echo "<br>"."<br>";
	
	$dayf=array(" ","Mon","Tue","Wed","Thu","Fri");
	for ($x=1;$x<=5;$x++){
		$per=1;
		while ($per<=$gym)
		{
			 $day1=$dayf[$x].$per;
			 $day=$dayf[$x];
			 
			 require "mathitisprog.php";
			 
			 $math1[$x][$per]=$name;
			 $room1[$x][$per] = $room;
			 $per++;
		}
    } //for loops

$_SESSION['room1']=$room1;

//*************************************
$apal=mysqli_query($con,"select * from apallages where mitroo='$mitroo' ");
while($rapal=mysqli_fetch_array($apal))
{
	$dayout=$rapal['dayout'];
	$key = array_search($dayout, $dayf);
	$perout=$rapal['perout'];
	$teachin=$rapal['teachin'];
	$d=$dayout.$perout;
	$sqa=mysqli_query($con,"select ".$d.",t.id,te.Name from timetable as t, teachers as te 
	      where t.Teacher=te.Name and te.PMP='$teachin'");
	 $rowa=mysqli_fetch_array($sqa);
     $id1=$rowa['id']+1;
	 $nam=$rowa['Name'];
     $sqa=mysqli_query($con,"select ".$d." from timetable where id='$id1'");
	 $rowa=mysqli_fetch_array($sqa);
     $mathx=$rowa["$d"]; 
	 //$ar=explode("/",$mathx);
	 $room1[$key][$perout]=$mathx;
	 $math1[$key] [$perout]=$nam;
}		   
		//*************************
echo "<table class='myTable' >
<tr style='border:2px solid black;font-size:14px'  >
<tr>
<th>Περ.</th>
<th>Δευτερα</th>
<th>Τρίτη</th>
<th>Τετάρτη</th>
<th>Πέμπτη</th>
<th>Παρασκευή</th>
</tr>";
for ($per=1;$per<=$gym;$per++){
	echo "<tr>";
	echo "<td>".$per."</td>";
	for ($k=1;$k<=5;$k++){
		$math=$math1[$k][$per];
		$s1=$room1[$k][$per];
		
		echo "<td>" . $s1."  (".$math.") ". "</td>";
		}
		echo "</tr>";
}
echo "</table>";

 ?>
<br /><br />

<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>