Question:
Date: 28-03-2019 00:42:56
(In Spanish)
<table align="center">
<?php do { ?>
<tr>
<td><?php
if($row_reg_hermanos['fecha_n'] == $row_consulta_genealogia_editar['fecha_n'])
{
echo '<span style="color:red">'.$row_reg_hermanos['fecha_n'].'</span>';
}
else {
echo '<span style="color:blue">'.$row_reg_hermanos['fecha_n'].'</span>';
}
?></td>
<td><?php echo $row_reg_hermanos['nombre_n']; ?></td>
<td><?php echo $row_reg_hermanos['apellido_pn']; ?></td>
<td><?php echo $row_reg_hermanos['apellido_mn']; ?></td>
</tr>
<?php } while ($row_reg_hermanos = mysql_fetch_assoc($reg_hermanos)); ?>
</table>
pero no termina de funcionar todo lo pone azul.
¿Que hago mal?
saludos y gracias de antemano Votes: 0 - Answers: 7 - Views: 16 Share on: Google Facebook Twitter LinkedIn Link
cambiar color del texto de una celda segun variable php[Resolved]
hola, gracias a una repuesta de Leonardo sobre esta pregunta en el foro intente esto en el codigo<table align="center">
<?php do { ?>
<tr>
<td><?php
if($row_reg_hermanos['fecha_n'] == $row_consulta_genealogia_editar['fecha_n'])
{
echo '<span style="color:red">'.$row_reg_hermanos['fecha_n'].'</span>';
}
else {
echo '<span style="color:blue">'.$row_reg_hermanos['fecha_n'].'</span>';
}
?></td>
<td><?php echo $row_reg_hermanos['nombre_n']; ?></td>
<td><?php echo $row_reg_hermanos['apellido_pn']; ?></td>
<td><?php echo $row_reg_hermanos['apellido_mn']; ?></td>
</tr>
<?php } while ($row_reg_hermanos = mysql_fetch_assoc($reg_hermanos)); ?>
</table>
pero no termina de funcionar todo lo pone azul.
¿Que hago mal?
saludos y gracias de antemano Votes: 0 - Answers: 7 - Views: 16 Share on: Google Facebook Twitter LinkedIn Link
Answers:
-
Date: 28-03-2019 07:14:31 Si sale color azul significa que tu "if($row_reg_hermanos['fecha_n'] == $row_consulta_genealogia_editar['fecha_n'])" esta dando false, prueba algo como esto para ver que valores se estan comparando (y mejor si intentas averiguar como hacer debug en PHP):
<table align="center"> <?php do { ?> <tr> <td> <?php if($row_reg_hermanos['fecha_n'] == $row_consulta_genealogia_editar['fecha_n']){ echo "<span style='color:red'>{$row_reg_hermanos['fecha_n']} == {$row_consulta_genealogia_editar['fecha_n']}</span>"; } else { echo "<span style='color:blue'>{$row_reg_hermanos['fecha_n']} == {$row_consulta_genealogia_editar['fecha_n']}</span>"; } ?> </td> <td><?php echo $row_reg_hermanos['nombre_n']; ?></td> <td><?php echo $row_reg_hermanos['apellido_pn']; ?></td> <td><?php echo $row_reg_hermanos['apellido_mn']; ?></td> </tr> <?php } while ($row_reg_hermanos = mysql_fetch_assoc($reg_hermanos)); ?> </table>
Votes: 0 - Link answer -
Date: 28-03-2019 08:29:02 Jorge de antemano gracias por tu pronta respuesta
pero ahora sale todo rojo y añade ==
????
gracias Votes: 0 - Link answer -
Date: 28-03-2019 10:59:06 Me imagine que saldría algo así, mira que puse que muestre los valores de $row_reg_hermanos['fecha_n'] y $row_consulta_genealogia_editar['fecha_n'] separados por un ==, si luego del == no salio nada significa que $row_consulta_genealogia_editar['fecha_n'] no tiene ningun valor, revisa eso primero, puedes hacer un var_dump($row_consulta_genealogia_editar['fecha_n'])
Respecto a lo que ambos salen rojo, al segundo span le puse style color red por error, cuando debio ser color blue (Ya lo cambie en el codigo de la respuesta anterior). Votes: 0 - Link answer -
-
Date: 28-03-2019 23:48:54 revisado $row_consulta_genealogia_editar['fecha_n'] si tiene valor
??? Votes: 0 - Link answer -
Date: 02-04-2019 16:20:11 Intenta:
Cambia esta linea
if($row_reg_hermanos['fecha_n'] == $row_consulta_genealogia_editar['fecha_n']){
Por esta
if($row_reg_hermanos['fecha_n'] != $row_consulta_genealogia_editar['fecha_n']){ Votes: 0 - Link answer -
Date: 02-04-2019 20:05:06 Hola,
bueno he cambiado == por != y por fin cabia el color, pero mi sorpresa esta que ahora
funciona tanto con != como con == (bueno la diferencia entre uno y otro son los colores)
ni idea de cual era el problema realmente, pero el caso es que funciona
muchas gracias a los dos
saludos Votes: 0 - Link answer
To actively participate in the community first must authenticate, enter the system.Sign In