<?php
session_start();
$menu=$_SESSION['menu'];
include $menu;
?><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:5px;font-size:11px; }
<p style="font-size:09px;"></p>
</style>

<h4>ΣΤΓΚΕΝΤΡΩΤΙΚΟ ΜΕΤΡΩΝ ΚΑΤΑ ΤΜΗΜΑ</h4>
<?php
require "dbconnect.php";
$sql = mysqli_query($con,"SELECT  Class_id FROM voithos ORDER BY Class_id ");
$i=1;
while($row=mysqli_fetch_array($sql))
{
  $tm[$row['Class_id']]=0;
  $kathi[$row['Class_id']]=0;
  $tmname[$i]=$row['Class_id'];
  $i++;
}
$tnum=$i--;

$sql = mysqli_query($con,"SELECT  tmima,SUM(periodoi) as tmimasum FROM kataggelia GROUP BY tmima ");

while($row=mysqli_fetch_array($sql))
{
  $tmima=$row['tmima'];
  $sumapo=$row['tmimasum'];
  $tm[$tmima]=$tm[$tmima]+$sumapo;
}

for($i=1;$i<=$tnum;$i++)
{
  $tmima=$tmname[$i];
  $sql2 = mysqli_query($con,"SELECT SUM(t.peramount) as totper,a.tmima  FROM timoria as t,allstudentinfo as a  
       WHERE t.stu_id=a.mitroo AND a.tmima='$tmima' GROUP BY a.tmima" );
  $row2=mysqli_fetch_array($sql2);
  $sumkath=$row2['totper'];
  $kathi[$tmima]=$kathi[$tmima]+$sumkath;	
}


echo "<br>"."ΠΑΙΔΑΓΩΓΙΚΆ ΜΕΤΡΑ ΓΙΑ ΤΑ ΤΜΗΜΑΤΑ : "."<br>"."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Α/A</th>
<th>ΤΜΗΜΑ</th>
<th>ΟΛΙΚΟ ΠΑΡΑΠΤΟΜΑΤΩΝ</th>
<th>ΟΛΙΚΟ ΚΑΘΥΣΤΕΡΗΣΕΩΝ</th>
<th>ΣΥΝΟΛΟ</th>
</tr>";	

$i=1;
for($i=1;$i<=$tnum;$i++)
{
echo "<tr>";
echo "<td>" .$i. "</td>";
echo "<td>". $tmname[$i]. "</td>";
echo "<td>". $tm[$tmname[$i]] . "</td>";
echo "<td>". $kathi[$tmname[$i]] . "</td>";
$sum=$tm[$tmname[$i]]+$kathi[$tmname[$i]];
echo "<td>". $sum . "</td>";
echo "</tr>"; 
}

echo "</table>";
//............
echo "<br>";



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