El evento de mi prueba está entre el día 5 y 23
<input type='date'/> de html5 no funciona en todos los navegadores, yo utilicé Opera.
Código PHP:
Ver original<style type="text/css">
table {
border: 1px solid #000; padding: 2px;font: 9px;
}
td {
border: 1px solid #999;
}
.rojo {
background-color: red;
}
.verde {
background-color: green;
}
.azul {
background-color: blue;
}
.gris {
background-color: #666;color: #aaa
}
</style>
<form id="ver_sorteos" name="" method="post" action="">
<!-- -->
Fecha:
<?php
// fija el select en una opción
if (isset($_POST['fecha'])) { echo "<input type='date' name='fecha' size='8' maxlength='10' value='".$_POST['fecha']."' />";
} else {
echo "<input type='date' name='fecha' size='8' maxlength='10' value='".date('Y-m-d')."' />"; }
?>
<!-- -->
<input type="submit" name="enviar">
</form>
<?php
/** conexión BBDD **/
require_once('base/funciones/f_bd.php');
conectadb('test');
/** **/
if(isset($_POST['enviar'])) { $aFechas['fecha_selec'] = $_POST['fecha'];
}
/** rango de fechas de prueba **/
$anio = 2013;
$mes = 8;
$dias_x_mes = 30;
/** Consulta BBDD **/
$sql = "SELECT * FROM eventos
WHERE
'".$aFechas['fecha_selec']."'
BETWEEN fecha_inicio AND fecha_fin;";
echo '<table>';
for($d=1; $d <= 31; $d++) {
//Crea fechas del ciclo 2013-08-1, 2013-08-2, 2013-08-3...
$f = $anio."-".$mes."-".$d . ' ';
// le da formato de fecha
if (($fecha == $aFechas['fecha_selec']) && ($fecha >= $aRst['fecha_inicio']) && ($fecha <= $aRst['fecha_fin'])) {
echo "<tr><td><span class='rojo'>".$fecha."</span> fecha+evento</td></tr>";
} elseif ($fecha == $aFechas['fecha_selec']) { /** fecha seleccionada **/
echo "<tr><td><span class='azul'>".$fecha."</span> fecha</td></tr>";
} elseif (($fecha >= $aRst['fecha_inicio']) && ($fecha <= $aRst['fecha_fin'])) { /** rango evento **/
echo "<tr><td><span class='verde'>".$fecha."</span> evento</td></tr>";
} else {
echo "<tr><td><span class='gris'>$fecha</span></td></tr>";
}
}
echo '</table>';
?>