PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 8th, 2002, 07:52 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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]&nbsp;-&nbsp;$myUhrzeiteh[$count]:$myUhrzeitem[$count]<br><a href='07.php?id=".$myID[$count]."'>".$myTitle[$count]."</a>";
echo "</td>";
echo "</tr>";
}
$count++;
}

echo "</table>";
echo "&nbsp;";
echo "</td>";
}
echo "</tr>";
}
?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > creating a timetable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway