Código:
<?php
$week = 1;
for ($i=1; $i<=date('t'); $i++) {
$day_week = date('N', strtotime(date('Y-m').'-'.$i));
$calendar [$week] [$day_week] = $i;
if ($day_week == 7) { $week++; };
}
?>
<?php
$Nombre_mes = date("F");
$Nombre_año = date("Y");
?>
<!DOCTYPE html>
<html>
<head>
<script>
function goLastMonth(month, year){
if (month == 1) {
--year;
month = 12;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year="+year;
}
function goNextMonth(month, year){
if (month == 12) {
++year
month = 1;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year"+year;
}
</script>
</head>
<body>
<table border="4" id="calendar" style="border: solid; border-color: #B45F04; background-color: #F7D358; font-family: segoe script;">
<thead>
<tr>
<td><center><input type="button" name="previousbutton" onclick="goLastMonth(<?php echo $month.",".$year ?>)" style="width:40px; cursor: pointer;" value="<<"></center></td>
<td colspan="5"><center><b><?php echo $Nombre_mes." de ".$Nombre_año; ?></b></center></td>
<td><center><input type="button" name="nextbutton" onclick="goNextMonth(<?php echo $month.",".$year ?>)" style="width:60px; cursor: pointer;" value=">>"></center></td>
</tr>
<tr>
<td><center><b>Lunes</b></center></td>
<td><center><b>Martes</b></center></td>
<td><center><b>Miércoles</b></center></td>
<td><center><b>Jueves</b></center></td>
<td><center><b>Viernes</b></center></td>
<td><center><b>Sábado</b></center></td>
<td><center><b>Domingo</b></center></td>
</tr>
</thead>
<tbody>
<?php foreach($calendar as $days) :?>
<tr>
<?php for ($i=1;$i<=7;$i++) :?>
<td>
<?php echo isset($days[$i]) ? $days[$i] : ''; ?>
</td>
<?php endfor; ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</body>
</html>
$week = 1;
for ($i=1; $i<=date('t'); $i++) {
$day_week = date('N', strtotime(date('Y-m').'-'.$i));
$calendar [$week] [$day_week] = $i;
if ($day_week == 7) { $week++; };
}
?>
<?php
$Nombre_mes = date("F");
$Nombre_año = date("Y");
?>
<!DOCTYPE html>
<html>
<head>
<script>
function goLastMonth(month, year){
if (month == 1) {
--year;
month = 12;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year="+year;
}
function goNextMonth(month, year){
if (month == 12) {
++year
month = 1;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year"+year;
}
</script>
</head>
<body>
<table border="4" id="calendar" style="border: solid; border-color: #B45F04; background-color: #F7D358; font-family: segoe script;">
<thead>
<tr>
<td><center><input type="button" name="previousbutton" onclick="goLastMonth(<?php echo $month.",".$year ?>)" style="width:40px; cursor: pointer;" value="<<"></center></td>
<td colspan="5"><center><b><?php echo $Nombre_mes." de ".$Nombre_año; ?></b></center></td>
<td><center><input type="button" name="nextbutton" onclick="goNextMonth(<?php echo $month.",".$year ?>)" style="width:60px; cursor: pointer;" value=">>"></center></td>
</tr>
<tr>
<td><center><b>Lunes</b></center></td>
<td><center><b>Martes</b></center></td>
<td><center><b>Miércoles</b></center></td>
<td><center><b>Jueves</b></center></td>
<td><center><b>Viernes</b></center></td>
<td><center><b>Sábado</b></center></td>
<td><center><b>Domingo</b></center></td>
</tr>
</thead>
<tbody>
<?php foreach($calendar as $days) :?>
<tr>
<?php for ($i=1;$i<=7;$i++) :?>
<td>
<?php echo isset($days[$i]) ? $days[$i] : ''; ?>
</td>
<?php endfor; ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</body>
</html>