Salve a tutti,
ho trovato questo script per un calendario:
codice:
<?php
if( (!$_GET['month']) && (!$_GET['year']) ) {
$month = date("m");
$year = date("Y");
}else{
$month = $_GET['month'];
$year = $_GET['year'];
}
$timestamp = mktime(0, 0, 0, $month, 1, $year);
$monthname = date("F", $timestamp);
?>
<style type="text/css">
.calroll {
background:#ccc;
}
.calroll:hover {
background:#666666;
}
</style>
<table style="width:125px; border-collapse:collapse;" border="1" cellpadding="3" cellspacing="0" bordercolor="#000">
<tr style="background:#ffbc37;">
<td colspan="7" style="text-align:center;" class="calroll">
<span style="font-weight:bold;"><?php echo $monthname . " " . $year; ?></span>
</td>
</tr>
<tr style="background:#ffbc37">
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">Su</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">M</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">Tu</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">W</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">Th</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">F</span>
</td>
<td style="text-align:center; width:15px;" class="calroll">
<span style="font-weight:bold;">Sa</span>
</td>
</tr>
<?php
$monthstart = date("w", $timestamp);
$lastday = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
$startdate = -$monthstart;
$numrows = ceil(((date("t", mktime(0, 0, 0, $month + 1, 0, $year)) + $monthstart) / 7));
for ($k = 1; $k <= $numrows; $k++) {
?><tr><?php
for( $i = 0; $i < 7; $i++) {
$startdate++;
if(($startdate <= 0) || ($startdate > $lastday)) {
//blank day
?><td style="background:#fff;"></td><?php
}else{
if( $startdate == date("j") && $month == date("n") && $year == date("Y") ) {
//this is today
?><td onclick="createform(event)" class="calroll"><?php echo date("j"); ?></td><?php
}else{
//other days
?><td onclick="createform(event)" class="calenderoff" onmouseover="this.className='calenderover';" onmouseout="this.className='calenderoff';"><?php echo $startdate; ?></td><?php
}
}
}
?></tr>
<?php } ?>
</table>
Come posso fare in modo che, se i giorni del mese corrispondono a quelli pescati dal mio db, appaiano marcati in rosso?
Posto anche la query:
codice:
$selezione = "SELECT * FROM calendario WHERE disponibilita LIKE 'no' ORDER BY mese";
$risultato=mysql_query($selezione,$link2);
while ($riga=mysql_fetch_row($risultato)) {
$giorno = $riga[2];
}
Grazie in anticipo per i suggerimenti!