SV: [PHP-DB] Current row of query

From: Date: Fri, 27 Sep 2002 12:28:34 +0000
Subject: SV: [PHP-DB] Current row of query
Groups: php.db 
Request: Send a blank email to php-db+get-22050@lists.php.net to get a copy of this message
Actually you dont need to keep track of the row number. Yoy could just alternate the two colors like this: while ( $row = mysql_fetch_array($result) ) { $bgCol = ( $bgCol == "#EADBC6"}?"#EFE1CE":"#EADBC6"; echo "......"; } hth Henrik Hornemann -----Oprindelig meddelelse----- Fra: Patrick Lebon [mailto:patrick@webation.com] Sendt: 26. september 2002 17:20 Til: php-db@lists.php.net Emne: Re: [PHP-DB] Current row of query Thanks, im currently doing something similar to this but I was wondering if there was an already defined variable that i could use rather then have to create a value and increment it myself. I guess am being picky, but was just curious as im new to php. This is how im currently doing it... $rowNum = 0; while ( $row = mysql_fetch_array($result) ) { $rowNum++; if ($rowNum % 2) { $bgCol = "#EADBC6"; } else { $bgCol = "#EFE1CE"; } echo "......"; }

« previous php.db (#22050) next »