Re: Current row of query
| From: | Patrick Lebon | Date: | Thu, 26 Sep 2002 15:19:56 +0000 |
| Subject: | Re: Current row of query | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22010@lists.php.net to get a copy of this message | ||
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 "......";
}
"Brad Bonkoski" <bbonkosk@tampabay.rr.com> wrote in message
news:3D9322B8.3076EC1A@tampabay.rr.com...
> 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: http://www.php.net/unsub.php
>