Comunidad de diseño web y desarrollo en internet online

Alternar colores

Citar            
MensajeEscrito el 20 Jun 2008 04:04 am
Hola, tengo un archivo php que muestra los resultados de una table en una base de datos, pero quiero saber como puedo hacer para que para esos resultados se alternen colores como blanco y gris blanco y gris, les dejo el codigo por cualquier cosa
Gracias :lol:


<?php require_once('Connections/result_db.php'); ?>
<?php
$maxRows_result_rs = 10;
$pageNum_result_rs = 0;
if (isset($_GET['pageNum_result_rs'])) {
$pageNum_result_rs = $_GET['pageNum_result_rs'];
}
$startRow_result_rs = $pageNum_result_rs * $maxRows_result_rs;

mysql_select_db($database_result_db, $result_db);
$query_result_rs = "SELECT * FROM esmmug_load_data";
$query_limit_result_rs = sprintf("%s LIMIT %d, %d", $query_result_rs, $startRow_result_rs, $maxRows_result_rs);
$result_rs = mysql_query($query_limit_result_rs, $result_db) or die(mysql_error());
$row_result_rs = mysql_fetch_assoc($result_rs);

if (isset($_GET['totalRows_result_rs'])) {
$totalRows_result_rs = $_GET['totalRows_result_rs'];
} else {
$all_result_rs = mysql_query($query_result_rs);
$totalRows_result_rs = mysql_num_rows($all_result_rs);
}
$totalPages_result_rs = ceil($totalRows_result_rs/$maxRows_result_rs)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {font-family: Arial, Helvetica, sans-serif}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }

-->
</style></head>

<body>
<table width="505" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="111" class="style1"><div align="center"><span class="style5">ID cliente </span></div></td>
<td width="204" class="style1"><div align="center"><span class="style5">Nombre</span></div></td>
<td width="170" class="style1"><div align="center"><span class="style5">Edad</span></div></td>
</tr>

<?php do { ?>
<tr>
<td class="style1"><div align="center"><?php echo $row_result_rs['id']; ?></div></td>
<td class="style1"><div align="center"><?php echo $row_result_rs['nombre']; ?></div></td>
<td class="style1"><div align="center"><?php echo $row_result_rs['edad']; ?></div></td>
</tr>
<?php } while ($row_result_rs = mysql_fetch_assoc($result_rs)); ?>
</table>
<br />
<table width="230" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($result_rs);
?>

Por pacognovellino

26 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Jun 2008 09:21 am
en el bucle pon in contador ( $i++ );

luego
if($i%2==0) {
$color = "blanco";
} else {
$color = "gris";
};

Por _CONEJO

BOFH

7639 de clabLevel

17 tutoriales
21 articulos

 

clabbrowser
Citar            
MensajeEscrito el 20 Jun 2008 04:19 pm
Gracias por tu ayuda :)

Por pacognovellino

26 de clabLevel



 

firefox
Citar            
MensajeEscrito el 21 Jun 2008 09:42 pm

Código :

(1==(@$iToggle*=(-1)))?'blanco' : 'gris'.!($iToggle=-1);

Por neohunter

Claber

563 de clabLevel

1 tutorial

 

Bogota, Colombia

opera

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.