Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/12/2007, 07:10
Avatar de seinkraft
seinkraft
 
Fecha de Ingreso: diciembre-2007
Mensajes: 119
Antigüedad: 16 años, 4 meses
Puntos: 1
Colorear fila dinamicamente

Holis a todos ando con un problemita, ya tengo el codigo para intercalar el color de las filas pero no puedo insertar de ninguna manera que se coloree de otro color al pasar el mouse por encima :S.

Me pueden ayudar?

Este es el codigo que intercala los colores
Código PHP:
<html>
<head>
<title>Alternar el color de las filas en paginación</title>
</head>
<body bgcolor=#FFFFFF>
<?
$dbhost
='localhost';
$dbusername='root';
$dbuserpass='xxxxer';
$dbname='xxxxer';

$con=mysql_connect($dbhost,$dbusername,$dbuserpass);
mysql_select_db($dbname,$con);

if (!isset(
$pg))
$pg 0// $pg es la pagina actual
$cantidad=12// cantidad de resultados por página
$inicial $pg $cantidad;

$pegar "SELECT * FROM users ORDER BY id";
$cad mysql_db_query($dbname,$pegar) or die (mysql_error());

$contar "SELECT * FROM users ORDER BY id";
$contarokmysql_db_query($dbname,$contar);
$total_records mysql_num_rows($contarok);
$pages intval($total_records $cantidad);

$style="font-family:Arial, Helvetica, sans-serif; font-size:12px;";
// Imprimiendo los resultados
        
echo "<table width='100%' border='0px' cellspacing='1'>
        <tr>
        <td bgcolor='"
.$color."' style='".$style."'>ID</td>
        <td bgcolor='"
.$color."' style='".$style."'>Nombre</td>
        <td bgcolor='"
.$color."' style='".$style."'>Edad</td>
        <td bgcolor='"
.$color."' style='".$style."'>Genero</td>
        <td bgcolor='"
.$color."' style='".$style."'>E. Civil</td>
        <td bgcolor='"
.$color."' style='".$style."'>Preferencia Sexual</td>
        <td bgcolor='"
.$color."' style='".$style."'>Ubicación</td>
        <td bgcolor='"
.$color."' style='".$style."'>E-mail</td>
        <td bgcolor='"
.$color."' style='".$style."'>Sitio Web</td>";

while(
$array mysql_fetch_array($cad)) {

   if (
$colorfila==0){
       
$color"#AAD5FF";
       
$style="font-family:Arial, Helvetica, sans-serif; font-size:12px;";
       
$colorfila=1;
    }else{
       
$color="#6AB5FF";
       
$style="font-family:Arial, Helvetica, sans-serif; font-size:12px;";
       
$colorfila=0;
    }

    echo 
"
    <tr>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['id']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['username']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['age']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['sex']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['marital']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['preference']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['location']."</td>
    <td bgcolor='"
.$color."' style='".$style."'>".$array['email']."</td>
    <td bgcolor='"
.$color."' style='".$style."'><a target='_blank' href='".$array['website']."'>".$array['website']."</td>
    </tr>"
;

}
echo 
"</table>";

// Cerramos la conexión a la base
$con=mysql_close($con);

// Creando los enlaces de paginación
//echo "<p>";
//if ($pg <> 0)
//{
//$url = $pg - 1;
//echo "<a href='alternarcolores.php?pg=".$url."'>&laquo; Anterior</a>&nbsp;";
//}
//else {
//echo " ";
//}

//for ($i = 0; $i<($pages + 1); $i++) {
//if ($i == $pg) {
//echo "<font face=Arial size=2 color=ff0000><b>&nbsp;$i&nbsp;</b></font>";
//}
//else {
//echo "<a href='alternarcolores.php?pg=".$i."'>".$i."</a>&nbsp;";
//}
//}

//if ($pg < $pages) {
//$url = $pg + 1;
//echo "<a href='alternarcolores.php?pg=".$url."'>Siguiente &raquo;</a>";
//}
//else {
//echo " ";
//}
//echo "</p>";
?>
</body>
</html>
y este es el que se tiene que intertar en los td del while
Código HTML:
<td onmouseover='this.style.background="#cc0000"' onmouseout='this.style.background="white"'>