Copied from my website:
http://www.acecoolco.com/tutorials/28/s … al_17.html
[code]<?php
// Set the day names
$days = array(‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’);
// some configuration
$calendar_width = ‘550px’;
$row_1_color = ‘FFFFFF’;
$row_2_color = ‘F8F8F8’;
$row_head_color = ‘E0E0E0’;
$row_highlight_color = ‘D0D0D0’;
// How many days are in the current month
$days_In_month = cal_days_in_month(CAL_GREGORIAN, date(‘m’), date(‘Y’));
// Gets the current day, day with 1st 2nd etc, day name, year (2004), month,
// month name
$current_day = date(‘d’);
$current_day_S = date(‘dS’);
$current_day_name = date(‘l’);
$current_year = date(‘Y’);
$current_month = date(‘m’);
$current_month_name = date(‘F’);
// Get the offset of the first day of the month
$first_day_Of_month = date(‘w’, mktime(0, 0, 0, $current_month, 1, $current_year));
// For each of the day names, print em out
$day_names = FALSE;
foreach ($days as $x => $y)
{
$day_names .= ‘
}
// Spacers for the offset of the first day of the month
$cal_weeks_days = “”;
$i = $first_day_Of_month + 1;
if ($first_day_Of_month != “0”)
{
$cal_weeks_days .= ’
}
// Cal days - The first day is 1, default with PHP is 0, so lets set it to 1
$day_i = “1”;
$ii = $i;
for ($i; $i <= ($days_In_month + $first_day_Of_month) ; $i++)
{
// $i is our color variable - Alternate row colors:
$color = ($i % 2) ? $row_1_color: $row_2_color;
// If the current day is sunday, make sure a new row gets set
if ($ii == 8)
{
$cal_weeks_days .= '</tr><tr>';
$ii = 1;
}
// If the day is the current day, highlight it with a special color
$extra = ($current_day == $day_i) ? 'background-color: ' . $row_highlight_color . ';': 'background-color: ' . $color . ';';
// Show the days.
$cal_weeks_days .= '<td valign="top" style="' . $extra . ' height: 65px;">' . $day_i . '</td>';
// Increment the day number and the week day number (ii)
$day_i++;
$ii++;
}
// Add end month spacers
if ((8 - $ii) >= 1)
{
$cal_weeks_days .= ’
}
// Echo the VALID HTML
echo <<< HTML
<html>
<head>
<title>Valid HTML Simple Calendar by Acecoolco</title>
<style type="text/css">
table,tr,td,th,tbody,TR,TD{
font-family: Verdana;
font-size: 8pt;
font-size: 11; color: #000000;
border-font-size: 11; color: #000000;
border-collapse: collapse;
}
</style>
</head>
<body>
<table border="1" cellpadding="1" cellspacing="1" width="$calendar_width">
<tr>
<td align="center" colspan="7" bgcolor="$row_head_color">$current_day_name the $current_day_S of $current_month_name, $current_year</td>
</tr>
<tr>
$day_names
</tr>
<tr>
$cal_weeks_days
</tr>
</table>
</body>
HTML;
?> [/code]