note 44554 added to ref.calendar

From: Date: Mon, 09 Aug 2004 18:48:20 +0000
Subject: note 44554 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-74339@lists.php.net to get a copy of this message
It's better version of calendar, sundays is on end of table and month is as parametr of function. I based on code by dindinha_debs at hotmail dot com <?php function calendar($month) { $s=0; // Get the calender info $t_days = cal_days_in_month(CAL_GREGORIAN, (date("m",$month)), date("Y",$month)); $day = date("w", mktime(0, 0, 0, date("m",$month), 1, date("Y",$month)))-1; if($day==-1) $day=6; ?> <table border="0"> <tr><th bgcolor="yellow" colspan= "7"> <?=date("F Y",$month )?></th></tr> <tr><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th> <th>Fri</th><th>Sat</th><th>Sun</th></tr> <? for ($i = 0; $i <= $t_days; $i++) { if ($day > 6) { $s++; echo "</tr>\n<tr>\n"; $day = 0; } //------------------------------------------------// if ($i == date("j")) { ?><td align = "center"><b><?echo $i; $day++; echo "</b></td>\n"; } else if ($i > 0) { ?><td align = "center"><?echo $i; $day++; echo "</td>\n"; } else if ($day > 0) { ?><tr><td colspan = "<?=$day?>"></td><? } //-----------------------------------------------// if ($i == $t_days && $day < 6) { ?><td colspan = "<?=(7-$day)?>"><? echo "</td>\n</tr>\n"; } } if ($s==4){print "<tr>\n<td>&nbsp</td></tr>"; } ?> </table></td> <? } $month = mktime(0, 0, 0, date("m"), date("d"), date("Y")); calendar($month); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.calendar.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44554 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44554&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44554&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74339) next »