<?php
include "scrinit.php";
$dt=$_SESSION['dt'];
$daymap = array('Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο');
$datedisp= date('d-m-Y', strtotime($dt)); 
$daytext = $daymap[date('w', strtotime($dt))]; 
?>
<!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" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:1px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>
<body>
<?php
require "dbconnect.php";
$gym=$_SESSION['gym'];
$day = date('D', strtotime($dt));
$dayper=$day.$gym;
echo $daytext.", ".$datedisp;
$sqlv=$dbcon->prepare("SELECT t.Name FROM efimeries as e,teachers as t  WHERE e.pmp=t.PMP and dayper=? ");
$sqlv->execute([$dayper]);
$rowv=$sqlv->fetch(PDO::FETCH_ASSOC);
$vdname=$rowv['Name'];

echo "<p style='font-size:16px;'>"."ΕΦΗΜΕΡΕΥΕΙ: ".$vdname."</p>";

echo "<br>"."<b>"."ΕΦΗΜΕΡΕΥΟΝΤΕΣ/ΟΥΣΕΣ ΠΕΡΙΟΔΟΥ"."</b>"."<br>";

$sqlv=$dbcon->prepare("SELECT e.*,t.Teacher,t.id  FROM efimeries as e,timetable as t  WHERE dayper LIKE ?  and e.pmp=t.pmp and (t.id%2)=1  order by e.dayper ASC");
$dp=$day.'%';
$sqlv->execute([$dp]);
while($rowv=$sqlv->fetch(PDO::FETCH_ASSOC))
{
	$dx=$rowv['dayper'];
	$per=substr($dx, -1);
	$vdname=$rowv['Teacher'];
	$ef[$per]=$vdname;
	$idtea[$per]=$rowv['id'];
}

echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<td >ΠΕΡ</td>
<td >ΙD</td>
<td>ΒΟΗΘΟΣ</td>
</tr>";
for ($k=1;$k<=$gym;$k++)
{
   echo "<tr>";
   echo "<td >".$k."</td>";
   echo "<td >".$idtea[$k]."</td>";
   echo "<td>".$ef[$k]."</td>";
   }
echo "</table>";
?>
</body>
</html>