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

Cita:
Iniciado por Keysher Ver Mensaje
Sin postear el código no creo que podamos hacer mucho más.
El codigo esta posteado al principio de todo...solo tienes que agregarle la parte html a td...y queda asi...

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 onmouseover=\"this.style.background='#c00'\" onmouseout=\"this.style.background='white'\">
    <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>
No se que otro codigo queres que te muestre :S, explicate.