
<?php
if ((!isset ($_GET['m']) || empty ($_GET['m']) || !is_numeric ($_GET['m'])) || (!isset ($_GET['y']) || empty ($_GET['y']) || !is_numeric ($_GET['y'])))
{
	$iMonth = date ("n", time ());
	$iYear = date ("Y", time ());
}
else
{
	$iMonth = $_GET['m'];
	$iYear = $_GET['y'];
}
printHtmlCalendar ("index.php?page=".$_GET['page'], $iMonth, $iYear);

function printHtmlCalendar ($sUrl, $iMonth, $iYear)
{
	if (ereg ("[?]", $sUrl))
	{
		$sUrl .= "&amp;";
	}
	else
	{
		$sUrl .= "?";
	}

	$aMonths = array (1 => "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");

	$iToday = mktime (0, 0, 0, $iMonth, 1, $iYear);

	$iTotalMonthDays = date ("t", $iToday);
	$iStartMonthWeekDay = date ("w", $iToday);
	$iLastMonthWeekDay = date ("w", mktime (0, 0, 0, date ("n", $iToday), $iTotalMonthDays, date ("Y", $iToday)));

	if ($iStartMonthWeekDay == 0) $iStartMonthWeekDay = 7;
	if ($iLastMonthWeekDay == 0) $iLastMonthWeekDay = 7;

	$iPlusTr = $iStartMonthWeekDay;
?>
<table summary='Kalender'>
	<caption>
		<?php echo $aMonths[date ("n", $iToday)]; ?>&nbsp;<?php echo date ("Y", $iToday); ?>
	</caption>
	<colgroup span='7' align='center' width='30px'></colgroup>
	<thead>
		<tr>
			<th scope='col' title='Maandag'>M</th>
			<th scope='col' title='Dinsdag'>D</th>
			<th scope='col' title='Woensdag'>W</th>
			<th scope='col' title='Donderdag'>D</th>
			<th scope='col' title='Vrijdag'>V</th>
			<th scope='col' title='Zaterdag'>Z</th>
			<th scope='col' title='Zondag'>Z</th>
		</tr>
	</thead>
<?php
	// Footer of table
	$iPrevMonth = $iMonth - 1;
	$iNextMonth = $iMonth + 1;
	$iPrevYear = $iYear;
	$iNextYear = $iYear;
	if ($iPrevMonth == 0)
	{
		$iPrevMonth = 12;
		$iPrevYear = $iYear - 1;
	}
	if ($iNextMonth == 13)
	{
		$iNextMonth = 1;
		$iNextYear = $iYear + 1;
	}
?>
	<tfoot>
		<tr>
			<td colspan='3' id='prev' title='<?php echo $aMonths[$iPrevMonth]; ?>'><a href='<?php echo $sUrl; ?>m=<?php echo $iPrevMonth; ?>&amp;y=<?php echo $iPrevYear; ?>'>&laquo; <?php echo substr ($aMonths[$iPrevMonth], 0, 3); ?></a></td>
			<td class='pad'>&nbsp;</td>
			<td colspan='3' id='next' title='<?php echo $aMonths[$iNextMonth]; ?>'><a href='<?php echo $sUrl; ?>m=<?php echo $iNextMonth; ?>&amp;y=<?php echo $iNextYear; ?>'><?php echo substr ($aMonths[$iNextMonth], 0, 3); ?> &raquo;</a></td>
		</tr>
	</tfoot>
	<tbody>
		<tr>
<?php
	// Empty Days @ the front
	if ($iStartMonthWeekDay != 1)
	{
?>
			<td class='pad' colspan='<?php echo ($iStartMonthWeekDay - 1); ?>'>&nbsp;</td>
<?php
	}
	// Days in the month
	for ($iDay = 1; $iDay <= $iTotalMonthDays; $iDay++, $iPlusTr++)
	{
		if (date ("j-n-Y", time ()) == ($iDay."-".$iMonth."-".$iYear))
		{
?>
			<td id='today'><?php echo $iDay; ?></td>
<?php
		}
		else
		{
?>
			<td><?php echo $iDay; ?></td>
<?php
		}
		if (($iPlusTr % 7) == 0)
		{
?>
		</tr>
		<tr>
<?php
		}
	}
	// Empty Days @ the end
	if ($iLastMonthWeekDay != 7)
	{
?>
			<td class='pad' colspan='<?php echo (7 - $iLastMonthWeekDay); ?>'>&nbsp;</td>
<?php
	}
?>
		</tr>
	</tbody>
</table>
<?php
}
?>



Dit is dezelfde code alleen met de HTML in de PHP. Dus niet zoals hierboven.
<?php
if ((!isset ($_GET['m']) || empty ($_GET['m']) || !is_numeric ($_GET['m'])) || (!isset ($_GET['y']) || empty ($_GET['y']) || !is_numeric ($_GET['y'])))
{
	$iMonth = date ("n", time ());
	$iYear = date ("Y", time ());
}
else
{
	$iMonth = $_GET['m'];
	$iYear = $_GET['y'];
}
printHtmlCalendar ("index.php?page=".$_GET['page'], $iMonth, $iYear);

function printHtmlCalendar ($sUrl, $iMonth, $iYear)
{
	if (ereg ("[?]", $sUrl))
	{
		$sUrl .= "&amp;";
	}
	else
	{
		$sUrl .= "?";
	}

	$aMonths = array (1 => "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");

	$iToday = mktime (0, 0, 0, $iMonth, 1, $iYear);

	$iTotalMonthDays = date ("t", $iToday);
	$iStartMonthWeekDay = date ("w", $iToday);
	$iLastMonthWeekDay = date ("w", mktime (0, 0, 0, date ("n", $iToday), $iTotalMonthDays, date ("Y", $iToday)));

	if ($iStartMonthWeekDay == 0) $iStartMonthWeekDay = 7;
	if ($iLastMonthWeekDay == 0) $iLastMonthWeekDay = 7;

	$iPlusTr = $iStartMonthWeekDay;

	print ("<table summary='Kalender'>");
	// Month & Year
	print ("\n	<caption>");
	print ("\n		". $aMonths[date ("n", $iToday)] ."&nbsp;". date ("Y", $iToday));
	print ("\n	</caption>");
	// Colgroup
	print ("\n	<colgroup span='7' align='center' width='30px'></colgroup>");
	// Day of the week
	print ("\n	<thead>");
	print ("\n		<tr>");
	print ("\n			<th scope='col' title='Maandag'>M</th>");
	print ("\n			<th scope='col' title='Dinsdag'>D</th>");
	print ("\n			<th scope='col' title='Woensdag'>W</th>");
	print ("\n			<th scope='col' title='Donderdag'>D</th>");
	print ("\n			<th scope='col' title='Vrijdag'>V</th>");
	print ("\n			<th scope='col' title='Zaterdag'>Z</th>");
	print ("\n			<th scope='col' title='Zondag'>Z</th>");
	print ("\n		</tr>");
	print ("\n	</thead>");
	// Footer of table
	$iPrevMonth = $iMonth - 1;
	$iNextMonth = $iMonth + 1;
	$iPrevYear = $iYear;
	$iNextYear = $iYear;
	if ($iPrevMonth == 0)
	{
		$iPrevMonth = 12;
		$iPrevYear = $iYear - 1;
	}
	if ($iNextMonth == 13)
	{
		$iNextMonth = 1;
		$iNextYear = $iYear + 1;
	}
	print ("\n	<tfoot>");
	print ("\n		<tr>");
	print ("\n			<td colspan='3' id='prev' title='". $aMonths[$iPrevMonth] ."'><a href='". $sUrl ."m=". $iPrevMonth ."&amp;y=". $iPrevYear ."'>&laquo; ". substr ($aMonths[$iPrevMonth], 0, 3) ."</a></td>");
	print ("\n			<td class='pad'>&nbsp;</td>");
	print ("\n			<td colspan='3' id='next' title='". $aMonths[$iNextMonth] ."'><a href='". $sUrl ."m=". $iNextMonth ."&amp;y=". $iNextYear ."'>". substr ($aMonths[$iNextMonth], 0, 3) ." &raquo;</a></td>");
	print ("\n		</tr>");
	print ("\n	</tfoot>");
	// Table Content
	print ("\n	<tbody>");
	print ("\n		<tr>");
	// Empty Days @ the front
	if ($iStartMonthWeekDay != 1)
	{
		print ("\n			<td class='pad' colspan='". ($iStartMonthWeekDay - 1) ."'>&nbsp;</td>");
	}
	// Days in the month
	for ($iDay = 1; $iDay <= $iTotalMonthDays; $iDay++, $iPlusTr++)
	{
		if (date ("d-n-Y", time ()) == ($iDay."-".$iMonth."-".$iYear))
		{
			print ("\n			<td id='today'>". $iDay ."</td>");
		}
		else
		{
			print ("\n			<td>". $iDay ."</td>");
		}
		if (($iPlusTr % 7) == 0)
		{
			print ("\n		</tr>");
			print ("\n		<tr>");
		}
	}
	// Empty Days @ the end
	if ($iLastMonthWeekDay != 7)
	{
		print ("\n			<td class='pad' colspan='". (7 - $iLastMonthWeekDay) ."'>&nbsp;</td>");
	}
	print ("\n		</tr>");
	print ("\n	</tbody>");
	print ("\n</table>\n");
}
?>
