note 43490 deleted from ref.calendar by aidan
| From: | aidan@php.net | Date: | Fri, 17 Dec 2004 04:18:15 +0000 |
| Subject: | note 43490 deleted from ref.calendar by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81889@lists.php.net to get a copy of this message | ||
Note Submitter: wasiq911 at hotmail dot com
----
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.