<?php
session_start();
?>
 <strong class="card-title"> <center> <img src="logo1.jpg" align="middle" /></center></strong>
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
						   <strong class="card-title"><center>School Time Table</center> </strong>
<?php
// Days of the week
// Generate the timetable
include 'dbc.php';

echo "<table border=1 width=100%>";
echo "<tr>";

 $sqlcr = "select * from tt_days";
$resultcr=$conn->query($sqlcr);

while($pppcr = $resultcr->fetch_assoc())
{
  $tname = $pppcr['tname'];	

		   echo"<th colspan=2><h2>" . $tname . "</h2></th>";
echo "</tr>";
 $sqlcr1 = "select * from tt_periods";
$resultcr1=$conn->query($sqlcr1);

while($pppcr1 = $resultcr1->fetch_assoc())
{
	

  $tname1 = $pppcr1['tname'];
   $all_name="";	
  $sqlsale = "SELECT * FROM timetable where pname='$tname1' and dname='$tname'";
$resultsale=$conn->query($sqlsale);
while($rowsale = $resultsale->fetch_assoc())
  {
  $all_name =  $all_name ."(". $rowsale['cname'] ."&nbsp;/&nbsp;". $rowsale['tname'] ."&nbsp;/&nbsp;". $rowsale['sname'].")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 
   }

echo "<tr>";
		   echo"<th>" . $tname1 . "</th>";
		   echo"<th>" . $all_name . "</th>";
		   echo "</tr>";
	}
	}
	
echo "</table>";
?>
