<?php
     $taxi=mb_substr($tmima, 0, 1, 'utf-8');
	 $tm3a=$taxi;
	 $tm3b=mb_substr($tmima, 2, 1, 'utf-8');
	 $tm3=$tm3a.$tm3b;
	 
	 $mth[1]=$tmima;
	 $r1=mysqli_query($con,"SELECT * FROM neosynd1 where mitroo='$mitroo'");
	 $ar1 = mysqli_fetch_array($r1);
	 $ind=1;
	 for ($d=1;$d<=12;$d++)
	 {
		 $mf='m'.$d;
		 if(!empty($ar1["$mf"]))
		 {
		   $mth[$ind]=$ar1["$mf"];
		   $ind++;
		 }
	 }
	 print_r($mth);
	 
	 $result = mysqli_query($con,"SELECT id,Teacher,($day1)  FROM timetable ");
	 
	 	 
	 
	 $rowx = mysqli_fetch_array($result);
	 
	 $name=$rowx['Teacher'];
	 
	 $mathimax=$rowx["$day1"];
	 $id=$rowx['id'];$nid=$id+1;
	 $teach=$name;
	 echo $teach.$c.$oldname;
   
   
   
   
	 $mathimax="";
	 
	  $found=0;
	  $sqlx = "SELECT synd,kathigitis  FROM syndidaskalies WHERE pmp='$mitroo'";
      $result1 = mysqli_query($con,$sqlx);
	  $c1=mysqli_num_rows($result1);
	  if ($c1 > 0 ) 
	  {
	  
while ($row4 = mysqli_fetch_array($result1)) 
 {
	      $name=$row4['kathigitis'];
	      $less=$row4['synd'];
		  $teach=$name;
		 
           include "mprog.php";
		  		  //'''''''''''''''''
          $res = mysqli_query($con,"SELECT id,($day1) FROM t1 WHERE Teacher='$name' AND ($day1)='$less' " ); 
          $c=mysqli_num_rows($res);
		  if ($c > 0) {
		    $row2 = mysqli_fetch_array($res);
			$mathimax=$row2["$day1"];
			$id=$row2["id"]; $nid=$id+1;
	        $res1 = mysqli_query($con,"SELECT * FROM t1 WHERE id='$nid'  " ); 
            $row3 = mysqli_fetch_array($res1); 
	        $room= $row3["$day1"];
			$found=1;
			break 1;
	   	    }
	     }
	  }
     
	 if ($found==0)
	 {
	 
	 include "mprog.php";
	 $res1 = mysqli_query($con,"SELECT * FROM t1 WHERE id='$nid'  " ); 
     $row3 = mysqli_fetch_array($res1); 
	 $room= $row3["$day1"];
	 if ($c == 2 AND $name==$oldname AND $taxi=='Α') {
		$rowx = mysqli_fetch_array($result);
		$name=$rowx['Teacher'];
		$mathimax=$rowx["$day1"];
		$id=$rowx['id']; $nid=$id+1;
		$teach=$name;
		 echo $teach."in".$c." ";
		include "mprog.php";
	       $res1 = mysqli_query($con,"SELECT * FROM t1 WHERE id='$nid'  " ); 
           $row3 = mysqli_fetch_array($res1); 
	       $room= $row3["$day1"];	
		} 
	 		 
	 }
	 
