While everyone's kicking in ideas... I don't think modulus (as someone else suggested) is that expensive, but I think this is the cheapest:
$evenodd = 0; $color[0] = '#cccccc'; $color[1] = '#999999'; while ($row = mysql_fetch_row($st)) { print "<tr><td bgcolor={$color[$evenodd]}>{$row['whatever']}</td></tr>"; $evenodd = 1 - $evenodd; } miguel On Fri, 10 May 2002, Jay Blanchard wrote: > [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 > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php