Re: Alternating Table Rows, Part Deux..

From: Date: Fri, 10 May 2002 20:25:28 +0000
Subject: Re: Alternating Table Rows, Part Deux..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97008@lists.php.net to get a copy of this message
Glenn Sieb wrote: > > Hey everyone! > > Thanks for all the hints--here's what my boss and I eventually came out with: > > /* ###################### > ## And for every row of data we pull, we create a table row... > ###################### */ > $company = 0; > $previous = ""; > for ($i = 0; $i < mssql_num_rows( $stmt ); ++$i) > { > $line = mssql_fetch_row($stmt); > $company += > (strcmp($previous,$line[0]) ? 1 : 0); > $color = (($company%2) ? "FFFFFF" : > "FFFF00"); > $cname = (strcmp($previous,$line[0]) > ? $line[0] : "&nbsp;"); > print ("<TR > > BGCOLOR=#$color>\n\t<TD>$line[2]</TD>\n\t<TD>$cname</TD>\n\t<TD>$line[3]</TD>\n</TR>\n"); > $previous = $line[0]; > } > print ("</TABLE>"); > > This not only takes care of the table row colors, but also removes > duplicate company names so it looks MUCH neater this way :)))) YIKES! I thought there was a SQL keyword for returning a unique rowset. Cheers, Rob. -- .-----------------. | Robert Cummings | :-----------------`----------------------------. | Webdeployer - Chief PHP and Java Programmer | :----------------------------------------------: | Mail : mailto:robert.cummings@webmotion.com | | Phone : (613) 731-4046 x.109 | :----------------------------------------------: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `----------------------------------------------'

« previous php.general (#97008) next »