<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js">
</script>
<script type="text/javascript">
$(function() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").html(html);
         }
     });
 }); 
});

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=900, height=300, top='+top+', left='+left);
}
</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:11pt; }
pre {color: blue;}
</style>
</script>
</head>
<body>
<?php
require "dbconnect.php"; 
require_once ("functions.php");
$usr=$_SESSION['usr'];
$tetramino=$_SESSION['tetramino'];
$mitroo=$_SESSION['usr'];
$r = mysqli_query($con,"select omp,tmima FROM allstudentinfo where mitroo='$mitroo' ");	
$row1=mysqli_fetch_array($r);
$omp=trim($row1['omp']);
$cl=mb_substr($tmima,0,1,'UTF-8');
if ($cl <> "Γ")
{
echo '<p style="color: red; font-size: 12pt;">ΠΡΟΦΟΡΙΚΗ ΒΑΘΜΟΛΟΓΙΑ ΕΞΕΤΑΖΟΜΕΝΩΝ ΜΑΘΗΜΑΤΩΝ Α ΤΕΤΡΑΜΗΝΟΥ (60%)</p>';
}
else
{
echo '<p style="color: red; font-size: 12pt;">ΒΑΘΜΟΛΟΓΙΑ ΕΞΕΤΑΖΟΜΕΝΩΝ ΜΑΘΗΜΑΤΩΝ Α ΤΕΤΡΑΜΗΝΟΥ</p>';	
}
$result1 = mysqli_query($con,"SELECT  * FROM bathmostetr  where mitroo='$mitroo' ");
$i=0;
$tel=array();
while ($row=mysqli_fetch_array($result1))
{
	
	$code=$row['code'];
	$bg=$row['bgrapto'];
	$bp=$row['bproforiko'];
	
	$result = mysqli_query($con,"select * FROM bathmoposo where id='$code' ");	
	$row1=mysqli_fetch_array($result);
	$math=$row1['mathima'];
	$tmima=$row1['tmima'];
	$q=mysqli_query($con,"select * from kodikoimathimatos where kodikos='$math'");
	$rowq=mysqli_fetch_array($q);
	$p1=$rowq['pgrapto'];
	$p2=$rowq['pproforiko'];
	$mathima=$math;
	$ekset=$rowq['ekset'];
	$cl=mb_substr($tmima,0,1,'UTF-8');
	include "pososta.php";
	
	if ($ekset==1)
	{
		$i++;
		$mathx[$i]=$rowq['mathima'];
		$t=$bg*$p1/100+$bp*$p2/100;
		$tel[$i]=round($t);
	}
}
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >";
for ($k=1;$k<=$i;$k++)
{	
  echo "<th>". $mathx[$k]."</th>";
}  
echo "<tr>";  
for ($k=1;$k<=$i;$k++)
{	
  echo "<td align='center'><b>".$tel[$k]."</b></td>";
}    
echo "</tr>";
echo "</table>";
?>

</body>
</html>