Código PHP:
<?php
$conexion=mysql_connect("localhost","root","") or die ("Error al conectar");
mysql_select_db("rural",$conexion) or die ("error al seleccionar base de datos");
$monthNames = Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<div id="calendar_div" name="calendar_div">
<table width="200">
<tr align="center">
<td bgcolor="#8FE8AB" style="color:#FFFFFF">
<table bgcolor="#77BF8D"width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
<td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table bgcolor="#77BF8D"width="100%" border="0" cellpadding="2" cellspacing="2">
<tr align="center">
<td colspan="7" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
</tr>
<tr>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>D</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>L</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>M</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>X</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>J</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>V</strong></td>
<td align="center" bgcolor="#8FE8AB" style="color:#FFFFFF"><strong>S</strong></td>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$mes = Date(n);
$startday = $thismonth['wday'];
$today = Date(j);
$anyo = Date(Y);
//////////////Empieza el juego/////////////////
$query = 'SELECT fecha_inicio FROM alquila';
$result = mysql_query($query);
$v = mysql_fetch_assoc($result);
$result=mysql_query($query);
//desconcatenar fecha//
while($v = mysql_fetch_assoc($result)){
$w = strpos ($v['fecha_inicio'],"-");
$x = substr ($v['fecha_inicio'],0,$w-=0);
//echo $x."<br/>";
$y = substr($v['fecha_inicio'],$w);
$y1 = strpos($y,"-");
$y2 = substr($y,1,$y1+=2);
//echo $y2."<br/>"; //
/***********ahora separamos el mes del dia***************/
$y3 = substr($y,4,$y1+=0);
//echo $y3."<br/>";
//echo $y3;
}
/////////////Termina el juego////////////////////
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>\n";
if($i < $startday) echo "<td></td>\n";
else{
if ($i - $startday + 1 == $today && $cMonth == $mes && $cYear == $anyo)
echo "<td style='color:red;' align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n";
else{
if ($y3 == $i - $startday + 1) echo "<td style='color:yellow;' align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n";
else
echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n";
}
}
if(($i % 7) == 6 ) echo "</tr>\n";
}
?>
</table>
</td>
</tr>
</table>
</div>
edit:
Nadie sabe?? =( la verdad es que me urge un poco y no encuentro la manera de conseguir lo que quiero, se que no es muy dificil pero ya estoy agobiado y no consigo sacarlo