<?php
session_start();
$menu= $_SESSION['menu'];
include "logo.php";
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:11px; }
<p style="font-size:11px;"></p>
</style>


</head>
<body  style="width:995px; margin:0 auto; ">

<?php 
require("dbconnect.php");

echo "mesoi oroi A tetraminou";

$taxi='Α0';
for ($k=1;$k<=6;$k++)
{
$tm=$taxi.$k;	
$sql=mysqli_query($con,"SELECT  mitroo,eponimo,onoma,sum(bathmosa) as suma,count(bathmosa) as cnta from  atetramino where mathima <> '' and tmima='$tm' group by mitroo order by mitroo");

echo "<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:16px'  >
<tr>
<th>Α/Α</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΑΘΗΤΗΣ</th>
<th>ΣΥΝΟΛΟ</th>
<th>ΑΡ. ΜΑΘ.</th>
<th>ΜΕΣΟΣ</th>
</tr>";
$i=1;$ca=0;$cb=0;	
while($row = mysqli_fetch_array($sql))
{  
   $sum=$row['suma'];
   $pm=$row['cnta'];
   if ($pm > 0)
   {
   $mesos=$sum/$pm;
   }
   $tmima=$tm;
   
   if ($pm > 5)
   {
   if ($mesos >= 18.5) {$cb++;}   
   echo "<tr>";
   echo "<td>". $i. "</td>";
   echo "<td>". $tmima. "</td>";
   echo "<td>". $row['eponimo'] ." ".$row['onoma']. "</td>";
   echo "<td>". $sum. "</td>";
   echo "<td>". $pm. "</td>";
   echo "<td>". round($mesos, 2). "</td>";
   echo "</tr>";
   $ca=$ca+$mesos;
   $i++;
   }
}
echo "</table>"; 
$plithos=$i--;
$a[$k]=$ca/$plithos;
$p[$k]=$plithos;
$ar[$k]=$cb;
}
echo "<br>";echo "<br>";

echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:16px'  >
<tr>
<th>ΤΜΗΜΑ</th>
<th>ΑΡ. ΜΑΘ</th>
<th>ΑΡΙΣΤΟΙ</th>
<th>ΜΕΣΟΣ</th>
</tr>";
for ($k=1;$k<=6;$k++)
{
   $tm=$taxi.$k;	
   echo "<tr>";
   echo "<td>".$tm. "</td>";
   echo "<td>".$p[$k]. "</td>";
   echo "<td>".$ar[$k]. "</td>";
   echo "<td>".round($a[$k], 2). "</td>";
   echo "</tr>";  
}  
echo "</table>"; 
//***********************

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

</body>
</html>