note 43490 added to ref.calendar

From: Date: Wed, 23 Jun 2004 05:55:57 +0000
Subject: note 43490 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-71528@lists.php.net to get a copy of this message
sup people!! I made this dynamic calendar for my site and thought I would share it with everybody. It's completely automatic so there's no need to modify anything...except maybe add your own styles of course! Hope this code helps somebody: <html> <body> <?php // Get the calender info $t_days = cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y")); $day = date("w", mktime(0, 0, 0, date("m"), 1, date("Y"))); ?> <table border = "1"> <tr><th bgcolor = "yellow" colspan = "7"><?php echo date("F Y"); ?></th></tr> <tr><th>Sun</th><th>Mon</th><th>Tue</th> <th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr> <?php for ($i = 0; $i <= $t_days; $i++) { if ($day > 6) { echo "</tr>\n<tr>\n"; $day = 0; } //------------------------------------------------// if ($i == date("j")) {?> <td align = "center"><b><?php echo $i; $day++; echo "</b></td>\n"; } else if ($i > 0) {?> <td align = "center"><?php echo $i; $day++; echo "</td>\n"; } else if ($day > 0) {?> <tr><td colspan = "<?php echo $day; ?>"><?php echo "</td>\n"; } //-----------------------------------------------// if ($i == $t_days && $day < 6) {?> <td colspan = "<?php echo 7 - $day; ?>"><?php echo "</td>\n</tr>\n"; } }?> </table> </body> </html> The above code creates a small and simple calendar table which highlights the current day in bold. I also took the time to make the source code well formatted. ---- Manual Page -- http://www.php.net/manual/en/ref.calendar.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43490 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43490&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43490&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71528) next »