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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:14px; }
<p style="font-size:14px;"></p>
</style>
<body>
<?php 
require "dbconnect.php"; 

$sql2 = mysqli_query($con,"SELECT DISTINCT tmima FROM allstudentinfo ORDER BY tmima ASC");
  
?>
<form  method='post'> 
  <label>Επέλεξε Τμήμα:</label>
  <select name='tmimaid' >
  <?php
  echo "<option value='---'>select</option>";
  while($row2 = mysqli_fetch_array($sql2) ) {
          echo "<option value='$row2[tmima]'>$row2[tmima]</option>";
      }
      ?>
 </select>
<input type="submit" name="submit1" value="Επιβεβαίωση Επιλογής" >
</form>
<?php
if (isset($_POST['submit1']))
{
	$tmima=$_POST['tmimaid'];

echo '<p style="color: blue; text-align: left; font-weight: bold;"> ΒΑΘΜΟΛΟΓΙΑ ΔΔΚ ΤΜΗΜΑΤΟΣ  </p>';
$mitr=array();
$sql = mysqli_query($con,"SELECT mitroo,onoma,eponimo FROM allstudentinfo where tmima='$tmima' order by eponimo,onoma");

echo '<p style="font-size: 14pt">' ."ΤΜΗΜΑ:"."<b>".$tmima."</b>".'</p>';
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>No.</th>
<th>A/M</th>
<th>ΜΑΘΗΤΗΣ/ΤΡΙΑ</th>
<th>ΧΑΡΑΚΤΗΡΙΣΜΟΣ ΔΔΚ</th>
<th>ΒΑΘΜΟΣ</th>";
$i=1;
while ($row=mysqli_fetch_array($sql))	
{
  $mitr[$i]=$row['mitroo'];
  $mit=$mitr[$i];
  $name[$i]=$row['eponimo']." ".$row['onoma'];
  $result = mysqli_query($con,"SELECT * FROM ddk WHERE mitroo='$mit'");
  $n=mysqli_num_fields($result)-1;
  $row1=mysqli_fetch_array($result);
  $sum=0;
 // if (mysqli_num_rows($result) > 0)
 // {
    for ($m=1;$m<=$n;$m++)
	{	
	    $field="f".$m;
		$sum=$sum+$row1["$field"];
	}
 // }
  
  if ($sum > 18 ) {$xr="ΕΞΑΙΡΕΤΙΚΗ";}
  elseif ($sum >= 14) {$xr="ΠΑΡΑ ΠΟΛΥ ΚΑΛΗ";}
  elseif ($sum >=9 ) {$xr="ΠΟΛΥ ΚΑΛΗ";}
  elseif ($sum >=5 ) {$xr="ΙΚΑΝΟΠΟΙΗΤΙΚΗ";}
  else {$xr="ΜΕΤΡΙΑ";}
  
  echo "<tr>";
  echo "<td>".$i."</td>";
  echo "<td>".$mitr[$i]."</td>";
  echo "<td>".$name[$i]."</td>";
  echo "<td>".$xr."</td>"; 
  echo "<td>".$sum."</td>";
  echo "</tr>";
  $i++;
}
echo "</table>";

echo "<br>"."<br>"."<br>";

echo "..............................."."<br>";
echo "ΥΠΟΓΡΑΦΗ ΚΑΙ ΟΝΟΜΑ ΥΤ:";
}
?> 
<br /><br /><br /><br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>
</body>
</html>