|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
creating a timetable
Hi there,
Can anyone help me with this code? I´m trying to get a timetable with the 5 weekdays and the hours from 9am to 11pm. These informations are in an array and the only problem is that every hour is output even if there is no class at that time. So, the result i am aiming for is that only the hours are being shown that have class(es) starting around this hour. It would be great if anybody has a solution! Cheers. dscab ------------------------------- <?php $sql = "SELECT * FROM sometable"; $result=mysql_query($sql); $i = 0; while($thisResult=mysql_fetch_object($result)) { $thisID[$i]=$thisResult->id; $thisTitle[$i]=$thisResult->title; $thisTimetable[$i]=$thisResult->starth; $thisDay[$i]=$thisResult->day; $thisTime[$i]=$thisResult->times; $thisTimesh[$i]=$thisResult->starth; $thisTimesm[$i]=$thisResult->startm; $thisTimeeh[$i]=$thisResult->endh; $thisTimeem[$i]=$thisResult->endm; $thisCategory[$i]=$thisResult->category; $i++; } $myTitleLenght = count($myTitle); echo "<table width="100%" border="1" bordercolor="#666666">"; $myDays = array('Monday','Tuesday','Wednesday','Thursday','F riday'); $myHours = array(9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) ; echo "<tr>"; foreach($myDays as $day) { echo "<td>"; echo $day; echo "</td>"; } echo "</tr>"; foreach($myHours as $starth) { $daycount=0; foreach($myDays as $day) { $daycount++; echo "<td valign=top>"; $count=0; echo "<table width="100%" border="0">"; foreach($myHours as $i) { if ($myTimetable[$count]==$starth and $myDay[$count]==$day) { if ($starth==$i) { echo "<tr>"; } echo "<td bgcolor=#ff9999>"; echo "<b>".$myTimetable[$count]."</b><br>"; echo "$myUhrzeitah[$count]:$myUhrzeitam[$count] - $myUhrzeiteh[$count]:$myUhrzeitem[$count]<br><a href='07.php?id=".$myID[$count]."'>".$myTitle[$count]."</a>"; echo "</td>"; echo "</tr>"; } $count++; } echo "</table>"; echo " "; echo "</td>"; } echo "</tr>"; } ?> |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > creating a timetable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|