RE: [PHP] Alternating table rows...
| From: | Jay Blanchard | Date: | Fri, 10 May 2002 19:20:07 +0000 |
| Subject: | RE: [PHP] Alternating table rows... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96993@lists.php.net to get a copy of this message | ||
[snip]
Is there a way for me to do one of the following:
1) Test to see if $i is an even or odd number?
2) Grab more than one line from the database at a time, and just put in two
table rows at once?
[/snip]
<?
$rowcount = 0;
while($dbrowa = mysql_fetch_object($dbseta)){
$dbrowb = mysql_fetch_object($dbsetb);
//change the color of alternating rows
$rowcount ++;
if ($rowcount == 1){
print("<tr bgcolor=\"#FFFF99\">\n");
}
elseif ($rowcount <> 1) {
print("<tr>\n");
$rowcount = 0;
}
This way you don't have to know even or odd.
$rowcount is 0
$rowcount is set to one and printed in a different color
$rowcount is set to two, which is not equal to one, so does elseif and is
set to zero
HTH!
Jay