Hi, I have implemented a calender and it is back-ended with a database, i want meetings etc that are held within the database to show up on the correct date on the calender. I am completely stuck...but this is what i have got so far (impart from the creating the table bit), has anyone got any ideas on how to crack it? $timestamp = mktime(0,0,0,$cMonth,1,$cYear); $maxday = date("t",$timestamp); $thismonth = getdate ($timestamp); $startday = $thismonth['wday']; for($i=0; $i<($maxday+$startday); $i++) { if(($i % 7) == 0) echo "<tr>\n"; if($i < $startday) echo "<td></td>\n"; else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n"; if(($i % 7) == 6 ) echo "</tr>\n"; Thank you!
First, I'd recommend not using a table and instead using unordered lists of seven list items each. You can style them like a traditional calendar if you want, but it gives you a lot more flexibility with the overall display. For logic, it sounds like you are going with a date-centric view (as opposed to event-centric). I'd wrap the display code with while ($currentTime < $end). Since you probably want to start with a Sunday, use something like while (date('l', $currentTime) != "Sunday") and set $currentTime = strtotime("-1 day", $currentTime);. If you want to break it into months, use a do while look that checks if the currentMonth is equal to the month you are displaying. Within the do while, you would start the UL then you would have a for ($i =0; $i < 7, $i++) to do the display of each day, then you'd have the end of the UL.