<?php
//// kataxorisi ston pinaka
$result = mysqli_query($con,"select count(pmp) as nc FROM dailytab");
$row = mysqli_fetch_array($result);
$n=$row['nc'];
mysqli_query($con,'TRUNCATE TABLE dailytab;'); 

//************************* prepare column list for query
$ta="";
$cols="id,pmp,Teacher,";
for ($i=1;$i<=$gym;$i++){$ta.="day".$i.',';}
$cols=$cols.$ta;
$cols = " (".rtrim($cols, ',').") ";

//*************************	
for ($i=1;$i<=$n;$i++) 
   {
	  $vlf="'".$i."','".$pmpt[$i]."','".$teach[$i]."',";
      $vl=""; 
	  for ($k=1;$k<=$gym;$k++) 
	  {
		  $val=$tprog[$i][$k];
		  $vl.="'".$val."',";
	  }
	  $vlf=$vlf.$vl;
	  $vlf = " (".rtrim($vlf, ',').") ";
	  mysqli_query($con,"INSERT INTO dailytab ".$cols. " values ".$vlf); 
	  
   } 