Quote:
Originally posted by CroMagnon
The <TD> tag looks good, and the logic seems right (I have copied the top portion of your code and tried it out on my server, and it seems to work).
First step I would say is to check the source code of the page from your browser - see if the TD tags are getting the right colour values printed out.
If they are there, then this is very odd - perhaps you have some CSS being included that is overriding your specifications? If they are not, it should give you a hint as to what's really happening. If you'd like, you can paste the HTML here and I'll have a look too. Also, make sure your table is closed off properly - </tr> and </table>. I don't think this would affect the colours, but web browsers are strange beasts.
To tell the user when there is no data, simply put a check just after the while loop - if there is one row of data, $rank will be incremented:
[code]print("<HR></td>");
}
if ($rank == 1) {
print( "No data!" );
}
|
Okay, here is the entire showdata.php:
<?php
$conn = @mysql_connect("localhost", "ssfceo101", "ssfceo23arm99");
if (!$conn) {
echo( "<P>No se pudo conectar " .
"al servidor MySQL.</P>" );
exit();
}
if (! @mysql_select_db("clientes") ) {
echo( "<P>No se puede encontrar " .
"la base de datos clientes!</P>" );
exit();
}
// Request all data
$result = mysql_query(
"SELECT * FROM newclients");
if (!$result) {
echo("<P>Error realizando el query: " .
mysql_error() . "</P>");
exit();
}
// Muestra todos los apellidos encontrados en la tabla
$colours = array( 0 => "#CCDFED", 1 => "#E1DDF3" );
$rank = 1;
[code]print("<HR></td>");
}
if ($rank == 1) {
print( "No data!" );
}
while($row = mysql_fetch_row($result)) {
$color = $colours[ ($rank % 2) ];
$rank++;
print("</tr><tr>");
print("<td width=\"6%\" bgcolor=\"$color\"><small><HR>");
print("<font face=\"Arial\ size=\"2\"><strong>Id:</strong><a href=\"borra.php?id=$row[0]\"><img src=\"images/tacho.gif\" alt=\"Borrar\" width=\"15\" height=\"22\" border=\"0\" align=\"right\">$row[0]</a></font></small><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Apellido:</strong>$row[1]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Nombre:</strong>$row[2]</font><br>");
print("<font face=\"Arial\" color=\"#CC0000\ size=\"2\"><strong>Teléfono:</strong>$row[4]</font><br>");
print("<font face=\"Arial\" color=\"#CC6600\ size=\"2\"><strong>Dni:</strong>$row[9]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Fecha:</strong>$row[5]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Hora:</strong>$row[6]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Abodado:</strong>$row[7]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Asunto:</strong>$row[8]</font><br>");
print("<font face=\"Arial\ size=\"2\"><strong>Donde nos conoció:</strong>$row[3]</font><br>");
print("<HR></td>");
}
?>
i also added the no data function but its complaining about some parse error. Checkit out.
Thanks.