//Here we start building the table heads
echo "<table border=1 width=294>";
echo "<tr><th colspan=7> $title $year </th></tr>";
echo "<tr><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
//This counts the days in the week, up to 7
$day_count = 1;
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td></td>";
$blank = $blank-1;
$day_count++;
}
The first part of this code very simply
echos the table tags, the month name, and the headings for the days of the week. Then we start a
while loop. What we are doing is echoing empty table details, one for each blank day we count down. Once the blank days are done it stops. At the same time, our $day_count is going up by 1 each time through the loop. This is to keep count so that we do not try to put more than seven days in a week.
[See working calendar example]