<?php
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:14pt; }
<p style="font-size:14px;"></p>
</style>
</head>

<body>
<h3> ΕΒΔΟΜΑΔΙΑΙΟ ΠΡΟΓΡΑΜΜΑ ΜΑΘΗΤΗ/ΤΡΙΑΣ </h3>
<?php
require "dbconnect.php";
$dayf=array(" ","Mon","Tue","Wed","Thu","Fri");
$ta="";
$cols="id,pmp,Teacher,";
for ($x=1;$x<=5;$x++)
{
  for ($i=1;$i<=8;$i++){$ta.=$dayf[$x].$i.',';}
}
$cols=$cols.$ta;
$cols = " (".rtrim($cols, ',').") ";
echo $cols;
$sql = mysqli_query($con,"select * from timetablea");
echo mysqli_num_rows($sql);
while($row=mysqli_fetch_array($sql))
{
	$idx=$row['id'];
	$t=$row['Teacher'];
	$pm=$row['pmp'];
	
	$vlf="'".$idx."','".$pm."','".$t."',";
	$vl="";
    for ($x=1;$x<=5;$x++)
    {
		$vk="";
		for ($p=1;$p<=8;$p++)
		{
			 
			$d=$dayf[$x].$p;
	        $v=$row["$d"]; 
			//echo $v;
			$v = preg_replace('/\s+/', '', $v);
			//echo $v;
		    $vk.="'".$v."',";
	    }
		echo "<br>".rtrim($vk, ',');
	    $vl=$vl.rtrim($vk, ',');
	}
	$vlf=$vlf.rtrim($vl, ',');
	$vlf = " (".rtrim($vlf, ',').") ";
	//echo "<br>".$vlf;
	mysqli_query($con,"INSERT INTO timetablead ".$cols. " values ".$vlf);		
}

?>
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>