note 46380 added to ref.calendar
| From: | info at sciomedia dot com | Date: | Sat, 09 Oct 2004 00:58:17 +0000 |
| Subject: | note 46380 added to ref.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78204@lists.php.net to get a copy of this message | ||
I modified the calendar below to make is so you can now cycle through the months. also changed the
color around a bit nothing big.
<html>
<body>
<center><table border="0">
<tr>
<td></td>
</tr>
<tr>
<?php
if($md == ""){$md = "0";}
if($md2 == ""){$md2 = "1";}
$mdNext1 = $md + 1;
$mdNext2 = $md2 + 1;
$mdBack1 = $md - 1;
$mdBack2 = $md2 - 1;
For($m=$md;$m<$md2;$m++){
print "<td>";
$lastmonth = mktime (0, 0, 0, date("m")+$m, date("d"), date("Y"));
$s=0;
// Get the calender info
$t_days = cal_days_in_month(CAL_GREGORIAN, (date("m",$lastmonth) ),
date("Y",$lastmonth) );
$day = date("w", mktime(0, 0, 0, date("m",$lastmonth ), 1,
date("Y",$lastmonth )));
?>
<table border = "1" bordercolor="#999999" cellpadding="0">
<tr bgcolor="#00CCFF"><th><a href='cal.php?md=<?php
echo("$mdBack1"); ?>&md2=<?php echo("$mdBack2"); ?>'
style="text-decoration:none " style="color:#000000
"><<</a></th><th colspan = "5"><?php echo (date("F
Y",$lastmonth )); ?></th><th><a href='cal.php?md=<?php
echo("$mdNext1"); ?>&md2=<?php echo("$mdNext2"); ?>'
style="text-decoration:none" style="color:#000000
">>></a></th></tr>
<tr><td align="center"
width='15'><b>Sun</b></td><td align="center"
width='15'><b>Mon</b></td><td align="center"
width='15'><b>Tue</b></td>
<td align="center"
width='15'><b>Wed</b></td><td align="center"
width='15'><b>Thu</b></td><td align="center"
width='15'><b>Fri</b></td><td align="center"
width='15'><b>Sat</b></td></tr>
<?php
for ($i = 0; $i <= $t_days; $i++)
{
if ($day > 6) {$s++;
echo "</tr>\n<tr>\n";
$day = 0; }
//------------------------------------------------//
if ($i == date("j")&& $m == 0) {?>
<td align = "center" bgcolor="#CCCCCC"><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"; }
}
if ($s==4){print "<tr>\n<td colspan='<?php echo 7 - $day;
?>'> </td></tr>";
}
?>
</table></td>
<?php
}?>
</tr></table>
</center>
</body>
</html>
----
Manual Page -- http://www.php.net/manual/en/ref.calendar.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46380
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46380&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46380&report=yes
Search -- http://master.php.net/manage/user-notes.php