Cita:
Iniciado por juancaalbarracin
Bueno se me ocurre que crees clases que te den los fondos de la celda que deseas. algo como:
Código CSS:
Ver original.verde {
background-color:#090;
}
.rojo{
background-color:#F00;
}
.amarillo{
background-color:#FF0;
}
Luego de esto solo deberas comparar y asignar tu clase:
Código PHP:
Ver original
if( $hactual > $hcita ) {
$clase="amarillo";
if( $hactual > $hsalida ) {
$clase="rojo";
} else {
$clase="verde";
}
Ahora lo colocas en la celda que deseas:
Y creo que estará listo
Sigo sin poder hacer que cambie de color. No tengo idea si es por el strtotime porque se pone de color verde, en el else.
<!DOCTYPE html>
<head>
<title>Vista</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
include 'conexion.php';
$server = "localhost";
$user = "root";
$pass = "";
$bd = "bus";
$conexion = mysqli_connect($server, $user, $pass, $bd) or die ("Error en la conexión");
//CÓDIGO PARA ORDENAR LA TABLA DE FORMA DESCENDENTE
$consulta = mysqli_query($conexion, "SELECT * from datos ORDER BY id DESC") or die("Error al consultar");
echo "<table border=1px>";
echo "<th>REGISTRO ID</th> <th>NOMBRE DEL CODUCTOR</th> <th>N. AUTOBUS</th> <th>ORIGEN</th> <th>DESTINO</th> <th>CLIENTE</th> <th>FECHA DE SALIDA</th> <th>HORA DE SALIDA</th> <th>HORA DE CITA</th> <th>EVENTO</th>";
//WHILE QUE PERMITE MOSTRAR LAS CONSULTAS UNA TRAS OTRA
while($arreglo = mysqli_fetch_array($consulta))
{
echo "<tr>";
echo "<td>".$arreglo['id']."</td>";
echo "<td>".$arreglo['nombre']."</td>";
echo "<td>".$arreglo['autobus']."</td>";
echo "<td>".$arreglo['origen']."</td>";
echo "<td>".$arreglo['destino']."</td>";
echo "<td>".$arreglo['cliente']."</td>";
echo "<td>".$arreglo['fSalida']."</td>";
echo "<td>".$arreglo['hSalida']."</td>";
echo "<td>".$arreglo['hCita']."</td>";
//VARIABLES PARA LA HORA
$hCita = strtotime($arreglo['hSalida']);
$hSalida = strtotime($arreglo['hSalida']);
$hActual = date("H:i");
//ESTE ES EL CÓDIGO QUE ME DIERON DE EJEMPLO
if($hActual < $hCita){
$clase = "amarillo";
if($hActual > $hCita){
$clase = "rojo";
}else{
$clase = "verde";
}
}
//Este if ayuda a mostrar la bandera en caso de que en el radiobutton se seleccione la opción de "Prioritario".
if($arreglo['opcion'] == ('Prioritario')){
echo "<td class='$clase'>" .$arreglo['opcion']. "<img src='flag.png'>" . "</td>";
}//IF
else{
echo "<td class='$clase'>" .$arreglo['opcion'] . "</td>";
}//ELSE
echo "</tr>";
//HEADER PARA ESTAR REFRESCANDO LAS CONSULTAS
header('refresh:3; url=vista.php');
}//WHILE
mysqli_close($conexion);
echo "</table>";
?>
<br><input name="button" type="button" onclick="window.close();" value="Cerrar" />
</body>
</html>