Prova questo. E' da migliorare ma secondo me è già un buono spunto.
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
.nomese {background-color:gray}
.feriale {background-color:yellow}
.festivo {background-color:green}
-->
</style>
</head>
<body>
<?php
//------ Esempio con il mese di Giugno 2007
$day = 01;
$month = 07;
$year = 2007;
//------ Primo giorno del mese
$firstDay = mktime(0,0,0,$month,$day,$year);
$annoData = date("Y",$firstDay);
$meseData = date("F",$firstDay);
//------ Mi posiziono sul primo lunedi
while (date("w",$firstDay) != 1) {
$firstDay = mktime(0,0,0,date("m",$firstDay),date("d",$firstDay) - 1,date("Y",$firstDay));
} // while (date("w",$firsDay) == 1)
?>
<div align="center">
<div align="center">Mese :<?php print "$meseData $annoData" ?></div>
<table summary="" cellpadding="1" cellspacing="0" border="1">
<th>Lunedi</th><th>Martedi</th><th>Mercoledi</th><th>Giovedi</th><th>Venerdi</th><th>Sabato</th><th>Domenica</th>
<?php
//------- Ho fino a 6 settimane x 7 gioni = 42
for ($set=1;$set<=6;$set++) {?>
<tr><?php
for ($gio=1;$gio<=7;$gio++) {
//------- Se la data corrente non è del mese allora sfondo grigio
// Se la data corrente è del mese e non si tratta di una domenica allora sfondo giallo
// Se la data corrente è del mese e si tratta di una domenica allora sfondo verde
$classGior = date("m",$firstDay) != $month ? "nomese" : (date("w",$firstDay) == 0 ? "festivo" : "feriale");?>
<td class="<?php print $classGior ?>"><?php print date("d",$firstDay) ?></td><?php
//------- Giorno successivo
$firstDay = mktime(0,0,0,date("m",$firstDay),date("d",$firstDay) + 1,date("Y",$firstDay));
} // for ($gio=1;$gio<=7;$gio++) ?>
</tr><?php
} // for ($set=1;$set<=6;$set++) ?>
</table>
</div>
</body>
</html>