
<?php
session_start();
$dt=$_SESSION['dt'];
include('dbconnect.php');
//collect the passed id
$id=$_GET['kathig'];
echo $id;
   $day=array("Mon","Tue","Wed","Thu","Fri");
   $result = mysqli_query($con,"SELECT * FROM timetable WHERE id='$id'  " ); 
   $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 <= 7) 
	  {
	  $dayf=$day[$i].$per;
	  $lesson= $row["$dayf"];
	  if (!empty($lesson))
	  {
	    $lesson=ltrim(rtrim($lesson));
	    $subj=$row1["$dayf"];
		$mathima[$ind]=$lesson;
		$ar=explode('/',$subj);
		$subject[$ind]= $ar[1];
		$ind++;
	  }
		$per++;
      }
	  $i++;
	 }
$subject=array_unique($subject);
$ind=$ind-1;

//loop through all returned rows
foreach ($subject as $sub){ 
          echo "<option value='$sub'>$sub</option>";
      }


