[Phpwm] How to get a single string from different queries?

Ray Masa raymasa at hotmail.com
Wed Apr 19 14:46:39 BST 2006


Hi all,

I am trying to join several database queries into a single string, but have 
not been able to do so, any suggestions?

Here is the PHP code:

<?php

mysql_connect("host", "user", "pass") or die(mysql_error());
mysql_select_db("realty") or die(mysql_error());

$address = mysql_query("SELECT listingsdbelements_field_value FROM 
en_listingsdbelements WHERE listingsdbelements_field_name = 'address'") or 
die(mysql_error());
while($row1 = mysql_fetch_array( $address )) {
// check to see if query is being fetched
echo $row1['listingsdbelements_field_value']. "<br />";
}

$city = mysql_query("SELECT listingsdbelements_field_value FROM 
en_listingsdbelements WHERE listingsdbelements_field_name = 'city'") or 
die(mysql_error());
while($row2 = mysql_fetch_array( $city )) {
// check to see if query is being fetched
echo $row2['listingsdbelements_field_value']. "<br />";
}

// join the above query in one string

$full_address=$city.', '.$address;


echo $full_address;

?>


The above give me the following output:

1200 Atwater Ave.
1240 Rue Drummond
Montreal
Westmount
H3G 1V7
H3A 1Y1
Resource id #3, Resource id #4


The individual queries are returning and echoing the results correctly, but 
the last string ($full_address) is giving me error (Resource id #3, Resource 
id #4).

Any ideas on how to solve this?

Thanks,

Ray





More information about the Phpwm mailing list