Re: syntax help please?

From: Date: Thu, 30 Aug 2001 01:23:09 +0000
Subject: Re: syntax help please?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-65140@lists.php.net to get a copy of this message
On Thu, 30 Aug 2001 00:15, Glyndower wrote: > I'm coming over from the ASP side and I'm trying to get a handle on > this stuff, I could use a little help with the how and wheres, please. > I do ok with the SQl bits, but the PHP bits are still being elusive... > > Heres my code: > > $sql = "SELECT > listnum,agentname,listAgent,streetName,streetNum,curprice,email_addr,of >ficen > ame,officephone,agentname,agentphone,bedrooms,full_baths,half_baths,cus >tomer Remarks FROM mlsdb WHERE mlsdb.statusCode = 'A' AND mlsdb.catgNum > = '1'"; > > $result = mysql_query($sql); > > //load it all into the associative array > > while(list($listnum,$agentname,$streetName,$streetNum) = > mysql_fetch_row($result)): > echo "$listnum $agentname $streetNum $streetName <br>"; > endwhile; > > ?> > > Which displays: > > 50730 Aubrey May Wyndwood Drive 0 > 873171 Tia Lingle Palm Trl 9903 > 902385 Anthony Kipen Normandy Blvd 6458 ... > > As you can see the $streetNum displays BEFORE the $streetName, I'm > assuming thats becuase thats the order they are in in the query..(?) > > Heres my "I'm a newbie" question... exactly how and where do I define > the variables so that i can use them in a different order than they are > in the query? Use extract ,which makes available variables of the same name as the fields in your table. $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { extract($row); echo "$listnum $agentname $streetNum $streetName <br>"; } -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Oxymoron: Weather Forecast.

« previous php.general (#65140) next »