<?php
include "scrinit.php";
include "logo.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
require("dbconnect.php");
$gym=$_SESSION['gym'];
if (isset($_POST['drasi1']))
{
$mitr = $_POST['mitr'];
$papo = $_POST['papo'];
$pm=$_POST['pm'];
$code=$_POST['code'];
$ekd=$_POST['ekd'];

$i=1;
while ($i<=9) 
{
	$met[$i]=0;
	if ($i >= $papo AND $i <= $pm) $met[$i]=1;
	$i++;
}
if (count($mitr) > 0) 
{
  $q1 = $dbcon->prepare("delete from ekdilosistu where code=?");
  $q1->execute([$code]);
  foreach ($mitr as $a)
  {
    $sql1= $dbcon->prepare("SELECT tmima FROM allstudentinfo WHERE mitroo=?");
	$sql1->execute([$a]);
	$row=$sql1->fetch(PDO::FETCH_ASSOC);
    $tmep=$row['tmima'];
    $sql=$dbcon->prepare("INSERT INTO ekdilosistu (code,pmp,tmima,p1,p2,p3,p4,p5,p6,p7,p8,p9) VALUES 
    (?,?,?,?,?,?,?,?,?,?,?,?)");
    $sql->execute([$code,$a,$tmep,$met[1],$met[2],$met[3],$met[4],$met[5],$met[6],$met[7],$met[8],$met[9]]);

  }
}
  include "epilogimathiton.php";
}
else
{
	include "epmathnew.php";
}
?>
</body>
</html>