<?php
session_start(); // start up your PHP session!
 if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΚΑΝΕΤΕ ΕΓΓΡΑΦΗ ΓΙΑ ΧΡΗΣΗΣ ΤΟΥ ΣΥΣΤΗΜΑΤΟΣ"."<BR>";
  sleep(3);
  header("Location: loginall.php"); /* Redirect browser */
  exit();
  }
$menu=$_SESSION['menu'];
include $menu;
?>

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

</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#mathsubid").bind("change", function() {
     $.ajax({
         url: "change1.php",
         data: "mathsubid="+$("#mathsubid").val(),
         success: function(html) {
             $("#codeid").html(html);
         }
     });
 }); 
});

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=900, height=300, top='+top+', left='+left);
}
</script>

</head>

<body>

<br><h3> ΕΠΙΛΟΓΗ  ΜΑΘΗΜΑΤΟΣ ΓΙΑ ΚΑΤΑΧΩΡΗΣΗ ΒΑΘΜΟΛΟΓΙΑΣ </h3>
<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$name = $_SESSION['n'];
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];

echo "<b>"." ΗΜΕΡΟΜΗΝΙΑ : "."</b>".$dt."<br>";

echo "<br>";echo "<br>";echo "<br>";
   $day=array("Mon","Tue","Wed","Thu","Fri");
   $result = mysqli_query($con,"SELECT * FROM timetable WHERE Teacher='$name'  " ); 
   $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;
	  $tmimax= $row["$dayf"];
	  if (!empty($tmimax)){
	      $tmimax=ltrim(rtrim($tmimax));
	      $subj=$row1["$dayf"];

		$tmima[$ind]=$tmimax;
		$ar=explode('/',$subj);
		$subject[$ind]= rtrim(ltrim($ar[1]));
		$mathsubj[$ind]=rtrim(ltrim($tmima[$ind]))."/".$subject[$ind];
	    $ind++;
	}
		$per++;
}
	  $i++;
	 }

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

?>

<form action='bathmo1.php' method='post'> 


    <label><b>Επιλογή Μαθήματος : </b></label><select name='mathsubid' id='mathsubid'>
     
      <?php
	echo "<option value=' '>Επέλεξε Τμήμα και Μάθημα</option>";
    foreach ($mathsubj as $m){ 		  
          echo "<option value='$m'>$m</option>";
      }
      ?>
     </select>
  

<label><b> Στοιχεία Διαγωνίσματος : </b></label>

      <select name='codeid' id='codeid' value= ></select>

<input type="submit" name="submitb" value="Επιβεβαίωση Επιλογής" >
    </form>

</body>
</html>