RE: [PHP] alternating row color--newbie help
| From: | Chris W. Parker | Date: | Thu, 15 Apr 2004 20:34:21 +0000 |
| Subject: | RE: [PHP] alternating row color--newbie help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-183564@lists.php.net to get a copy of this message | ||
Montagna, Dan <mailto:Montagna@PVPC.ORG>
on Thursday, April 15, 2004 1:02 PM said:
> Hi everyone,
hi.
> for($i = 0; $i < $numofrows; $i++) {
> $row = mysql_fetch_array($result); //get a row from our result set
> if($i % 2) { //this means if there is a remainder
> echo "<TR bgcolor=\"yellow\">\n";
> } else { //if there isn't a remainder we will do the else
> echo "<TR bgcolor=\"white\">\n";
> }
> echo
>
"<TD>".$row['name']."</TD><TD>".$row['phonenumber']."</TD><TD>".$row['ag
e'].
> "</TD>\n";
> echo "</TR>\n";
> }
<?php
for($i = 0; $i < $numofrows; $i++)
{
...
$row_color = ($i % 2 == 0) ? "yellow" : "white" ;
echo "<tr bgcolor=\"$row_color\">\n";
...
}
?>
hth,
chris.