<?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>

<?php
require "dbconnect.php"; 
echo '<p style="color: blue; text-align: left; font-weight: bold;"> ΜΕΣΟΙ ΟΡΟΙ ΜΑΘΗΜΑΤΩΝ  </p>';
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>Α/Α</th>
<th>ΜΑΘΗΜΑ</th>
<th>ΜΑΘΗΤΕΣ</th>
<th>ΜΕΣΟΣ ΟΡΟΣ</th>";
$sql2 = mysqli_query($con,"SELECT distinct b.mathima FROM bthis as b,allstudentinfo as al 
        where b.mitroo=al.mitroo and al.tmima like 'Γ%' ORDER BY b.mathima ASC");
//$sql2 = mysqli_query($con,"SELECT distinct mathima FROM bthis where exetasi > 0");		
echo mysqli_num_rows($sql2);
$k=1;
while($row2 = mysqli_fetch_array($sql2) ) 
{
 $math=$row2['mathima'];
 $result = mysqli_query($con,"select b.*,al.eponimo,al.onoma,al.tmima FROM bthis as b,allstudentinfo as al
          where b.mitroo=al.mitroo and b.mathima='$math' and al.tmima like 'Γ%' ");
 $pl=mysqli_num_rows($result);





$i=1;$tot1=0;$tot2=0;$c=0;
$bathmos=$mitr=$tmima=$name=$b1=$b2=$ex=$mot=array();
while($row = mysqli_fetch_array($result))
{
 $mitr[$i]=$row['mitroo'];
 $tmima[$i]=$row['tmima'];
 $name[$i]=$row['eponimo']." ".$row['onoma'];;
 $b1[$i]=$row['bathmosa']; 
 $b2[$i]=$row['bathmosb'];
 $ex[$i]=$row['exetasi'];	
 $mot[$i]=($b1[$i]+$b2[$i])/2;
 $tot1=$tot1+$mot[$i];
 $bathmos[$i]=$mot[$i];
 if ($ex[$i] > 0)
 {
    $bathmos[$i]=(($mot[$i]*70)+($ex[$i]*30))/100;
	$tot2=$tot2+$ex[$i];
 }
 else
 {
	 $tot2=0;
 }
 $c++;
 $i++;
}


  $moc[$k]=$c;
  $motetr[$k]=$tot1/$c;
  $moex[$k]=$tot2/$c;
  $mth[$k]=$math;
 
 if($moex[$k]> 0) 
 {
  echo "<tr>";
  echo "<td>". $k . "</td>";
  echo "<td>". $math . "</td>";
  echo "<td>". $c . "</td>";
  echo "<td >". $moex[$k] . "</td>";
  echo "</tr>";
  
 $k++;
 }
}
echo "</table>";

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

</body>
</html>