Re: Alternating table rows...

From: Date: Fri, 10 May 2002 18:50:26 +0000
Subject: Re: Alternating table rows...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96986@lists.php.net to get a copy of this message
Glenn Sieb wrote:
Hi everyone, I have a PHP script that reads data from an MS SQL server and outputs the data into a table. I've been asked if I can alternate the colors of the rows to make the report more legible. The relevant piece of code looks like: for ($i = 0; $i < mssql_num_rows( $stmt ); ++$i)
                             {
                                     $line = mssql_fetch_row($stmt);
                                     print ("<TR><FONT COLOR=#$color><TD>$line[2]</TD><TD>$line[0]</TD><TD>$line[3]</TD></TR>");
                             }
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? Thanks for your help in advance! Glenn --- Glenn E. Sieb, System Administrator Lumeta Corp. mailto:ges@lumeta.com +1 732 357-3514 (V) +1 732 564-0731 (Fax)
$color=($i%2) ? "grey" : "white; will let you change the background color depending on whether or not $i is even or odd.

« previous php.general (#96986) next »