Plz frenz help me.
I want to display timetable of college lectures using PHP/MySQL.
I stored the information about lectures in Lectures_Info table. It has following fields:
Subject_Name- name of subject,
Lecture_Start-start timing of lecture(like 09:00),
Lecture_Day-Day of lecture(like Monday,Tuesday).
I attached image for the format of timetable.
There are two arrays for lecture start timings and week days.
I am not getting how to display the subject names in corresponding time and days slot.
So far i tried following code:
<?php $query_schedule = "SELECT Subject_Name, Lecture_Day, Lecture_Start FROM lecture_info WHERE Teacher_Id=$tid";
$schedule = mysql_query($query_schedule, $database) or die(mysql_error());
$row_schedule = mysql_fetch_assoc($schedule);
$lectureStartArray=array('09:00','10:00','11:30','12:30','14:15','15:15');
$weekdays=array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$subject=array();
$lectureDay=array();
$lectureStart=array();
$i=0;
do{
$subject[$i]=$row_schedule['Subject_Name'];
$lectureDay[$i]=$row_schedule['Lecture_Day'];
$lectureStart[$i]=$row_schedule['Lecture_Start'];
$i++;
}while($row_schedule = mysql_fetch_assoc($schedule));
?>
Using these arrays i tried to print subjects as follows:
<table border=1 cellpadding=3>
<tr>
<td bgcolor="#0099CC"><strong>Hour</strong></td><?php foreach($weekdays as $day) {?>
<th bgcolor="#FF0066"><strong><?php echo $day;?></strong></th>
<?php }?>
</tr>
<?php foreach($lectureStartArray as $val){?>
<tr>
<td bgcolor="#0099CC"><strong><?php echo $val;?></strong></td><?php foreach($weekdays as $day) {
$val=$val.':00';
if(in_array($val,$lectureStart)){
$i=array_search($val,$lectureStart);
if($day==$lectureDay[$i])
?>
<th bgcolor="#FF99FF"><?php echo $subject[$i];?></th><?php }
else?>
<th bgcolor="#FF9966"></th>
<?php }?>
</tr>
<?php
}
?>
</table>
But there is something wrong with this code. Plz help me.