<?php
echo $name;
$day=array(" ","Mon","Tue","Wed","Thu","Fri");
$result = mysqli_query($con,"SELECT * FROM timetable WHERE pmp='$pmp'  " ); 
$row = mysqli_fetch_array($result);
$id=$row['id']+1;
$q = mysqli_query($con,"SELECT * FROM timetable WHERE id = '$id'");
$row1 = mysqli_fetch_array($q);

for ($i=1;$i<=5;$i++)
{
  for ($per=1;$per<=$gym;$per++){
  $dayf=$day[$i].$per;
  $m=$row["$dayf"];
  $s=$row1["$dayf"];
  //$subject = trim(strrev(strstr(strrev((strstr($s, '/'))), '(')), '/(');
  $ss=explode('/',$s);
  $room=$ss[0];
  $subject=$ss[1];
  if ($m <> NULL) {
		  $math1[$i][$per]=$m;
		  $sub[$i][$per]=$subject;
		  $rm[$i][$per]=$room;}
  else {
	  $math1[$i][$per]=" ";
	  $sub[$i][$per]=" ";
	  $rm[$i][$per]=" ";}
  }
}



$d1=$row["$thisdp"];


  //...............................................................
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=$sub[$k][$per];
		$rm1=$rm[$k][$per];
		if ($s1 <> " ") 
		{
		   echo "<td>" . $math." / ".$s1."(".$rm1.")" ."</td>";
		}
		else
		{
		   echo "<td>" . " "."</td>";	
		}
		}
		echo "</tr>";
}
echo "</table>";