<?php
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
td.right1{text-align: right;}
input.right{  text-align:right;  }
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";

echo "<table style='width:900px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>A/A</th>
<th>ΜΗΤΡΩΟ</th>
<th>ΜΑΘΗΤΗΣ/ΜΑΘΗΤΡΙΑ</th>
<th>ΤΜΗΜΑ</th>
<th>Περ1</th>
<th>Περ2</th>
<th>Περ3</th>
<th>Περ4</th>
<th>Περ5</th>
<th>Περ6</th>
<th>Περ7</th>
<th>ΣΥΝΟΛΟ</th>
<th>ΠΟΙΝΗ</th>
<th>ΑΠΟΥΣΙΕΣ</th>
</tr>";

$sql = mysqli_query($con,"SELECT * FROM allstudentinfo order by tmima " );
$i=1;
$row = mysqli_fetch_array($sql);
while (!empty($row))
{
  $tmima=$row['tmima'];
 
  while($tmima=$row['tmima'])
  {
    $stname=$row['eponimo']." ".$row['onoma'];
    echo "<tr>";
	echo "<td>".$i. "</td>";
	$mitr=$row['mitroo'];
	echo "<td>".$mitr. "</td>";
    echo "<td>".$stname. "</td>";
    echo "<td>".$tmima. "</td>";
    $sql1 = mysqli_query($con,"SELECT SUM(peramount) as stimo FROM timoria  WHERE stu_id='$mitr'  " );
    $row2=mysqli_fetch_array($sql1);

    $sqlk= mysqli_query($con,"SELECT period,count(period) AS cper FROM apousies WHERE mitroo='$mitr' AND apousia=0 AND kath > 0  group by period " );	
    $kath=array();$sum=0;
    while($row1=mysqli_fetch_array($sqlk))
    {
     $kath[$row1['period']]=$row1['cper'];
     $sum=$sum+$row1['cper'];
    }
    for ($k=1;$k<=7;$k++)
    {
	  echo "<td>".$kath[$k]. "</td>";
    }
    echo "<td>".$sum. "</td>";
	echo "<td>".$row2['stimo']. "</td>";
	$sql3 = mysqli_query($con,"SELECT COUNT(period) as sumap FROM apousies WHERE mitroo='$mitr' AND apousia=1  " );
	$row3=mysqli_fetch_array($sql3);
	echo "<td>".$row3['sumap']. "</td>";
    echo "</tr>";
    $row = mysqli_fetch_array($sql);
	$i++;
   }
$tmima=$row['tmima'];
echo $tmima;   
}
 
echo "</table>";	


 ?>

<br /><br /><br />

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