Here's code for a Month-At-A-Glance
| From: | Joey Garcia | Date: | Mon, 13 Nov 2000 17:16:53 +0000 |
| Subject: | Here's code for a Month-At-A-Glance | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-3813@lists.php.net to get a copy of this message | ||
I was trying to make a Month-At-A-Glance and I finally got it to work so I
thought I'd share it too. What you need to get this to work is the "Day Of
The Week Number", i.e., Sunday=1 and the "Number Of Days in the Month". I
also used Allan Kent's Date/Time Column at PHPBuilder to get the required
information. I also added the process I used to the requried information.
I just wanted to give something back to those who have helped me on thie
News Group.
Enjoy!
<pre>
<html>
<head>
<title>Month-At-A-Glance</title>
</head>
<body>
<?php
// *** These are here if you need to calculate the required values ***
// *** Reference Allan Kent's Column on Dates at PHPBuilder.com
/*
$thismonth = mktime($hours, $minutes,$seconds ,$month, $day,$year);
$firstday = mktime($hours, $minutes,$seconds ,$month, 1,$year);
$dayofweek=date("D",$thismonth);
$firstdayofmonth=date("D",$firstday);
$weekdaynum=array("Sun"=>1,"Mon"=>2,"Tue"=>3,"Wed"=>4,"Thu"=>5,"Fri"=>6,"Sat
"=>7);
$dayNumber=$weekdaynum[$dayofweek];
*/
print "<table width=80% align=center border=1>\n";
print"<tr><th>Sun(1)</th><th>Mon(2)</th><th>Tue(3)</th><th>Wed(4)</th><th>Th
u(5)</th><th>Fri(6)</th><th>Sat(7)</th></tr>";
$daysinmonth=31;//For July 2000 this is 31 days
$daycount=1;
$firstdayofmonth=7;//For July 2000 this is Sat, or day 7
for ($week=1; $week <= 6; $week++){
print"<tr>\n";
for($day=1; $day <=7; $day++){
if( ($day >= $firstdayofmonth) || ($week >1) ){
print"<td height=40px>";
if ($daycount <= $daysinmonth){
print $daycount;
$daycount++;
/* You could insert data here with something like this
print $monthData[$week][$day] if loaded elsewhere*/
}
print" </td>\n";
}
else{
print"<td height=40px> </td>\n";
}
}
print"\n</tr>\n";
}
print"</table>";
?>
</body>
</html>
</pre>