Re: Current row of query

From: Date: Thu, 26 Sep 2002 15:20:14 +0000
Subject: Re: Current row of query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-22011@lists.php.net to get a copy of this message
then add an extra conditional to check if $i is equal to 0, or start $ off as 1so, for ($i=1, $i<$num_rows+1; $i++) -or- if ($i==0) //treat as even either way woudl work. -Brad "Hutchins, Richard" wrote: > Not sure here, but you might also run into a problem if you start your if > statement with $i=0. If PHP does not treat the value 0 as even or odd, your > first row is most likely going to be purple along with your second row. I > know it's nitpicky, but I could see myself spending half an hour trying to > figure out why the code works, but not the way I want it to. > > > -----Original Message----- > > From: Brad Bonkoski [mailto:bbonkosk@tampabay.rr.com] > > Sent: Thursday, September 26, 2002 11:10 AM > > To: Patrick Lebon; php-db@lists.php.net > > Subject: Re: [PHP-DB] Current row of query > > > > > > oops... > > > > I meant: > > (if $i is odd) > > ... > > > > because $i would be the current index in the array. > > > > > > Brad Bonkoski wrote: > > > > > why not this? > > > > > > $result = mysql_query("Select * from table'); > > > $num_rows = mysql_num_rows($rows); > > > > > > for ($i=0; $i<$num_rows, $i++) > > > { > > > $row = mysql_fetch_array($result); > > > if ($num_rows is odd) > > > { > > > print $row with BG color of red; > > > } > > > else > > > { > > > printf $row with BG color of purple; > > > } > > > } > > > > > > HTH > > > -Brad > > > > > > Patrick Lebon wrote: > > > > > > > Is there a mysql or array variable for the current row of > > a query array? > > > > I want to alternate background colours for each row of > > the query output so i > > > > need to know the current row number. > > > > > > > > Thanks > > > > > > > > -- > > > > PHP Database Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: ¤KÇ˵nãj > > > > þJÐdñ�http://www.php.net/unsub.php > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#22011) next »