Pulling data from a table into a array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)) {
 			$checked[]=$list;
		}
	}
print_r($checked);

This is what it is putting out

Array ( [0] => Array ( [0] => 1 ) [1] => Array ( [0] => 7 ) [2] => Array
( [0] => 9 ) [3] => Array ( [0] => 10 ) [4] => Array ( [0] => 12 ) [5]
=> Array ( [0] => 14 ) [6] => Array ( [0] => 24 ) [7] => Array ( [0] =>
25 ) [8] => Array ( [0] => 37 ) [9] => Array ( [0] => 38 ) ) 


This what I what the Array to look like

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 12 [4] => 25 [5] => 37 )

What can I do to make it come out this way. 
The database table looks like this I only whant the data from the
amenityID in the order it finds it in the table

ID  listingID  amenityID
1       1         4
2       1         2
3       2         1
4       1         10

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux