PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
PastorHank
Forum Contributor
Posts: 117 Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country
Post
by PastorHank » Fri Dec 22, 2006 6:04 pm
Would someone please tell me the correct syntax to use to determine which row of a resultset I am working on?
The result set is returned with
Code: Select all
while ($row = mysql_fetch_array($result)) {
extract($row);
I know the array starts at row[0] but for the life of me, none of my if statements seem to work.
Thank you
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Dec 22, 2006 6:07 pm
Because it can't create variable names that are numbers, try the EXTR_PREFIX_INVALID flag for extract().
(#10850)
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Dec 22, 2006 6:15 pm
or use mysql_fetch_array($result, MYSQL_ASSOC)
and/or do not extract the elements but use the array like e.g. echo $row['fieldname'];
PastorHank
Forum Contributor
Posts: 117 Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country
Post
by PastorHank » Fri Dec 22, 2006 6:32 pm
Thank you. After enough beating my head against the wall, I simply used a counter set to zero and incremented it after use....it was very much a 'duh' moment.