Re: Pulling data from a table into a array

From: Date: Mon, 15 Nov 2004 08:24:24 +0000
Subject: Re: Pulling data from a table into a array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202022@lists.php.net to get a copy of this message
On Monday 15 November 2004 15:54, Richard wrote: > I am using mysql_fetch_row to pull data from a table to fill an array > But I am not getting the data into the array the way I whant it to be. > > $query = "SELECT amenityID FROM property_amenity where listingId = > '$listingId'"; > $results = mysql_query($query); > if ($results) { > while ($list=mysql_fetch_row($results)) { You are really *much* better off using mysql_fetch_assoc(). > $checked[]=$list; Instead of of slapping the whole of $list into $checked, just stick in the bit you want, namely amenityID. So assuming you've changed to using mysql_fetch_assoc(): $checked[]=$list['amenityID']; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* > Where in the US is Linus? He was in the "Promise Land". -- David S. Miller <davem@caip.rutgers.edu> */

« previous php.general (#202022) next »