*relief
What I'm doing is - I retrieve a record and then check if the day is between SAT - WED. Then I store each date that falls on a SAT in an array for that particular day. In this way all exams that are scheduled for say Saturday are in the array Saturday[]. Then I print out these arrays (SAT-WED) one after the other, which is why they don't appear in weekly order. I can't seem to get the logic working ...
PHP Code:
<?php
//include the necessary files
include 'header.htm';
include 'inc.global.php';
//Initializing necessary variables
$Saturday[] = NULL;
$Sunday[] = NULL;
$Monday[] = NULL;
$Tuesday[] = NULL;
$Wednesday[] = NULL;
?>
<table width="85%" border="0" align="center">
<tr>
<td width="6%"><img src="images/arrow_green.gif" width="44" height="42" align="top"></td>
<td width="89%"> </td>
<td width="5%"><img src="images/table_padding.gif" width="44" height="42" align="top"></td>
</tr>
<tr>
<td> </td>
<td><p class="myHeading">Exam Schedule</p>
<p align="center">Month: <a href="?month=1">Jan</a> | <a href="?month=2">Feb</a> | <a href="?month=3">Mar</a> | <a href="?month=4">Apr</a> | <a href="?month=5">May</a> | <a href="?month=6">Jun</a> | <a href="?month=7">Jul</a> | <a href="?month=8">Aug</a> | <a href="?month=9">Sep</a> | <a href="?month=10">Oct</a> | <a href="?month=11">Nov</a> | <a href="?month=12">Dec</a> </p>
<table width="85%" border="0" align="center">
<tr>
<td align="center" bgcolor="#E9E9E9"><div align="center">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr bgcolor="#CECEFF">
<th height="12">Saturday</th>
<th height="12">Sunday</th>
<th height="12">Monday</th>
<th height="12">Tuesday</th>
<th height="12">Wednesday</th>
</tr>
<tr bgcolor="#FFFFFF" valign="top">
<?php
$sessionQuery = 'SELECT `sessionID`, DATE_FORMAT(`date`, \'%d-%b-%y\') AS `date`, DATE_FORMAT(`time`, \'%h:%i %p\') AS `time`, DAYNAME(`date`) AS `day` FROM `schedule`';
//Retrieve the schedule from the database
$sessionQueryResult = @mysql_query($sessionQuery) or die('<div class="error">Invalid query: ' . mysql_error().'/<div>');
if((mysql_num_rows($sessionQueryResult)) < 1)
{ echo '<tr><td colspan=5><div class="error" align="center">No exams scheduled for this month</div></td></tr>'; }
else
{
while ($row = mysql_fetch_array($sessionQueryResult, MYSQL_ASSOC))
{
switch($row['day'])
{
case ($row['day'] == 'Saturday'):
$Saturday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
break;
case ($row['day'] == 'Sunday'):
$Sunday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
break;
case ($row['day'] == 'Monday'):
$Monday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
break;
case ($row['day'] == 'Tuesday'):
$Tuesday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
break;
case ($row['day'] == 'Wednesday'):
$Wednesday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
break;
} //switch
} //while
echo '<td width=20%><div align="center">';
for($i=0; $i<count($Saturday); $i++)
{
echo $Saturday[$i];
}
echo '</div></td>';
echo '<td width=20%><div align="center">';
for($i=0; $i<count($Sunday); $i++)
{ echo $Sunday[$i]; }
echo '</div></td>';
echo '<td width=20%><div align="center">';
for($i=0; $i<count($Monday); $i++)
{
echo $Monday[$i];
}
echo '</div></td>';
echo '<td width=20%><div align="center">';
for($i=0; $i<count($Tuesday); $i++)
{
echo $Tuesday[$i];
}
echo '</div></td>';
echo '<td width=20%><div align="center">';
for($i=0; $i<count($Wednesday); $i++)
{
echo $Wednesday[$i];
}
echo '</div></td>';
?>
</tr>
</table>
</div></td>
</tr>
</table>
<p>
<div class="redAlert">
<div align="center">Note: If you are not a registered candidate, you cannot sit for the exam.</div>
</div>
</td>
<td> </td>
</tr>
</table>
<?php
include 'footer.htm';
?>
Bookmarks