<?php
session_start();
ob_start();
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<?php 

require("dbconnect.php");
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
$day = date('D', strtotime($dt));
$d1=$day."1";$d2=$day."2";$d3=$day."3";$d4=$day."4";$d5=$day."5";$d6=$day."6";$d7=$day."7";
$result = mysqli_query($con,"SELECT id,Teacher,".$d1.",".$d2.",".$d3.",".$d4.",".$d5.",".$d6.",".$d7." FROM timetable ");

$timep=array();$teacht=array();$roomt=array();
$j=0;
while ($row = mysqli_fetch_array($result))
{
   $id=$row['id'];
   $teacht[$id]=$row['Teacher'];
   for ($i=1;$i<=$gym;$i++) 
   {
      $in=$day.$i;
      $timep[$id][$i]=$row["$in"];
	  if($row["$in"] <>"" AND !($id & 1)){
	  	  $ar=explode("/",$row["$in"]);
		  $j++;
		  $roomt[$j]=$ar[0];
		  }
   }
}

?>

</body>
</html>