<?php
session_start();

?>

<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 "<br>";

$sql=  mysqli_query($con,"SELECT  dilosimath.* FROM dilosimath,allstudentinfo  WHERE allstudentinfo.mitroo=dilosimath.mitroo and allstudentinfo.tmima LIKE 'Β%' " );

mysqli_query($con,'TRUNCATE TABLE mathall;');
$kat4=0;
while ($row=mysqli_fetch_array($sql))
{
   $mitroo=$row['mitroo'];
   $mth[1]="ΝΕΑ ΕΛΛΗΝΙΚΑ";
   $mth[2]=$row['exam2'];
   $mth[3]=$row['exam3'];
   $mth[4]=$row['exam4'];
  
   
   for ($i=1;$i<=4;$i++)
   {
	  if ($mth[2] <> "" AND $mth[3] <> "" AND $mth[4] <> "") {
		  $sql1= "INSERT INTO mathall (mitroo,mathima) VALUES ('$mitroo', '$mth[$i]' )" ;   
	      if (!mysqli_query($con,$sql1)){die('Error: ' . mysqli_error($con));}}
   } 
  
}

$query = "SELECT mathima,COUNT(mitroo) FROM mathall GROUP BY mathima"; 
	 
$result = mysqli_query($con,$query) or die(mysqli_error());

// Print out result

echo "ΕΞΕΤΑΖΩΜΕΝΑ ΜΑΘΗΜΑΤΑ Β ΛΥΚΕΙΟΥ";
echo "<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:16px'  >
<tr>
<th>Μάθημα</th>
<th>Αριθμός</th>
</tr>";	
while($row = mysqli_fetch_array($result)){
   echo "<tr>";
   echo "<td>". $row['mathima']. "</td>";
   echo "<td>". $row['COUNT(mitroo)'] . "</td>";
 
   echo "</tr>";
}
echo "</table>"; 

 ;
$result = mysqli_query($con,"SELECT  count(DISTINCT(mitroo)) as stus FROM mathall " );
$row=mysqli_fetch_array($result);

echo "<br>"."ΣΥΝΟΛΟ ΜΑΘΗΤΩΝ : ".$row['stus'];

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

</body>
</html>