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

?>

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

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
<style type="text/css">
input.right{  text-align:right;  }
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
</style>
</script>

</head>

<body>
<h3> ΒΑΘΜΟΙ ΤΜΗΜΑΤΟΣ </h3>

<?php
require "dbconnect.php"; 
//$dt=$_SESSION['dt'];

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

$result = mysqli_query($con,"select b.*,al.eponimo,al.onoma,al.tmima FROM bathmoiab as b,allstudentinfo as al
          where b.mitroo=al.mitroo and b.mathima='$math' ");
echo '<p style="color: blue; text-align: left; font-weight: bold;"> ΑΝΑΛΥΤΙΚΗ ΒΑΘΜΟΛΟΓΙΑ ΤΜΗΜΑΤΟΣ  </p>';

echo "ΜΑΘΗΜΑ:".$math."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>No.</th>
<th>A/M</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΑΘΗΤΗΣ/ΤΡΙΑ</th>
<th>A ΤΕΤΡ</th>
<th>B ΤΕΤΡ</th>
<th>ΔΙΑΦΟΡΑ</th>
<th>ΜΟ ΤΕΤΡ</th>
<th>ΕΧΕΤΑΣΗ</th>
<th>ΔΙΑΦΟΡΑ</th>
<th>ΒΑΘΜΟΣ</th>";

$i=1;
while($row = mysqli_fetch_array($result))
{
 $mitr=$row['mitroo'];
 $tmima=$row['tmima'];
 $name=$row['eponimo']." ".$row['onoma'];;
 $b1=$row['bathmosa']; 
 $b2=$row['bathmosb'];
 $ex=$row['exetasi'];	
 $dif1=$b2-$b1;
 $mot=($b1+$b2)/2;
 $dif2=$mot-$ex;
 $bathmos=(($mot*70)+($ex*30))/100;
	
  echo "<tr>";
  echo "<td>". $i;
  echo "<td>". $mitr . "</td>";
  echo "<td>". $tmima . "</td>";
  echo "<td >". $name . "</td>";
  echo "<td >". $b1 . "</td>";
  echo "<td >". $b2 . "</td>";
  if ($dif1 >=0 and $dif1 <=3)
   
	{
	   echo "<td>"."<p align=right>".$dif1."</td>";
	   }
	    else if ($dif1 >= 4)
	{
		echo "<td bgcolor='#6FFA0C'>"."<p align=right>".$dif1."</td>";
	}
	else
    {
	echo "<td bgcolor='#FF0000'>"."<p align=right>".$dif1."</td>";
    }
	
	echo "<td >". $mot . "</td>";
	if ($ex > $mot)
   	{
	  echo "<td bgcolor='#6FFAaC'>"."<p align=right>".$ex."</td>";
	}
	else
		{
	   echo "<td>"."<p align=right>".$ex."</td>";
	   }
	echo "<td >". $dif2. "</td>";
	echo "<td >". $bathmos . "</td>";
	echo "</tr>";
    $tot1=$tot1+$mot;
	$tot2=$tot2+$ex;
	$i++;
}
$ns=$i--;

  $mo1=$tot1/$ns;
  $mo2=$tot2/$ns;
echo "</table>";  
  echo "ΜΕΣΟΣ ΤΕΤΡΑΜΗΝΩΝ : ".number_format($mo1,2)."<br>";
   echo "ΜΕΣΟΣ ΟΡΟΣ ΕΞΕΤΑΣΗΣ : ".number_format($mo2,2)."<br>";
}




?>
<br><br>
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>

</body>
</html>