<?php
$day=array("Mon","Tue","Wed","Thu","Fri");
$subject=$mathsubj=array();

   $result = mysqli_query($con,"SELECT * FROM timetable WHERE pmp='$usr'  " ); 
   $row = mysqli_fetch_array($result);
   $c = mysqli_num_rows($result);
   $id1=$row['id']+1;
   $result1 = mysqli_query($con,"SELECT * FROM timetable WHERE id='$id1'  " ); 
   $row1 = mysqli_fetch_array($result1);
   $i=0;
   $ind=1;
   while($i <= 4)
   {
	  $per=1;
	  while ($per <= $gym) 
	  {
		  $dayf=$day[$i].$per;
		  $lesson= $row["$dayf"];
		  if (!empty($lesson))
		  {
			$lesson=trim($lesson);
			$subj=$row1["$dayf"];
			$mathima[$ind]=$lesson;
			$ar=explode('/',$subj);
			$subject[$ind]= $ar[1];
			$mathsubj[$ind]=ltrim($mathima[$ind])."/".ltrim($subject[$ind]);
			$ind++;
		  }
		  $per++;
      }
	  $i++;
   }

$mathsubj=array_unique($mathsubj);
$ind=$ind-1;