<?php
include "scrinit.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 green;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>
</head>
<body>


<?php
require "dbconnect.php";
$name=$_SESSION['n'];
$usr=$_SESSION['pmp'];
$flg=$_SESSION['flg'];
$ekd=$ekdilo;
$dt=date('d-m-Y');
?><h4>ΕΠΙΛΟΓΗ ΜΑΘΗΤΩΝ ΓΙΑ ΤΗ ΔΡΑΣΤΗΡΙΟΤΗΤΑ <?php echo "<b>".$ekd."</b>"; ?> </h4><?php

$sql = "SELECT code,perapo,permexri FROM ekdilosi WHERE onoma = '$ekd' ";
$result = $dbcon->prepare($sql);
$result->execute([$ekd]);
$row=$result->fetch(PDO::FETCH_ASSOC);
$code=$row['code'];
$papo=$row['perapo'];
$pm=$row['permexri'];

$s=$dbcon->prepare("select pmp from ekdilosistu where code='$code'");
$s->execute([$code]);
$stuin=array();
$i=1;
while($row=$s->fetch(PDO::FETCH_ASSOC))
{
	$stuin[$i]=$row['pmp'];
	$i++;
}

$sql = "SELECT mitroo,tmima,eponimo,onoma  FROM allstudentinfo order by tmima,eponimo,onoma ASC ";
$result = $dbcon->prepare($sql);
$result->execute();
?>
<form  method="post" name ="epilogi" action = "epmathnew2.php">
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:520px; height: 650px">
<?php
echo "<table style='width:500px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>ΜΗΤΡΩΟ</th>
<th>ΤΜΗΜΑ</th>
<th>ΟΝΟΜΑΤΕΠΩΝΥΜΟ</th>
<th></th>
<th>ΕΠΙΛΟΓΗ</th>
</tr>";
$i=1;
while ($row=$result->fetch(PDO::FETCH_ASSOC)) 
  { 
    $am[$i]=$row['mitroo'];
	if(in_array($am[$i],$stuin))
	{
	   $checked = "checked";
	}
	else
	{
		$checked = "";
    }
	$tm1[$i]=$row['tmima'];
	$namet[$i]=$row['eponimo']." ".$row['onoma'];;
	echo "<tr>";
	echo "<td>".$am[$i]."</td>";
	echo "<td>".$tm1[$i]."</td>";
	echo "<td>".$namet[$i]."</td>";
	echo "<td>"." "."</td>";
    echo "<td ALIGN=center>"."<input type='checkbox' name='mitr[]' value='$am[$i]'  {$checked} >"."</td>";
	echo "</tr>";
    $i++;
}
echo "</table>";
?>
</div>
<?php

    echo "<input type='hidden' name='tmep' value='$tm1'>";
	echo "<input type='hidden' name='papo' value='$papo'>";
	echo "<input type='hidden' name='pm' value='$pm'>";
	echo "<input type='hidden' name='code' value='$code'>";
	echo "<input type='hidden' name='ekd' value='$ekd'>";

?>

<br>
<input type="submit" name="drasi1" value="Επιβεβαίωση Επιλογών" >

 </form> 
 
</body>
</html>