youvegotwood Posted July 31, 2008 Share Posted July 31, 2008 Hello, I am trying to combine these two query's. Each one works separately but I need to perform a query that includes BOTH. $query1 = "SELECT * FROM Listings WHERE lattitude BETWEEN $latminus AND $latplus"; $query2 = "SELECT * FROM Listings WHERE longitude BETWEEN $lonminus AND $lonplus"; The current PHP looks like the following (which works, however I need to add the additional query) <? $query = "SELECT * FROM Listings WHERE lattitude BETWEEN $latminus AND $latplus"; $results = mysql_query($query); while($row = mysql_fetch_object($results)) { echo ' var point = new GLatLng( '.$row->lattitude.','.$row->longitude.'); var marker = createMarker(point, <b>Some stuff to display in the Info Window</b>); map.addOverlay(marker);'; } ?> Thanks in advance for your help! Link to comment https://forums.phpfreaks.com/topic/117589-php-mysql-combine-2-select-querys/ Share on other sites More sharing options...
cooldude832 Posted July 31, 2008 Share Posted July 31, 2008 so then combine them??? Select * from Listings where latitude Between ($var1 and $var2) and longitude Between($var3 and $var4) Link to comment https://forums.phpfreaks.com/topic/117589-php-mysql-combine-2-select-querys/#findComment-604834 Share on other sites More sharing options...
youvegotwood Posted July 31, 2008 Author Share Posted July 31, 2008 Hmmm when I change the query to this I get a Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/content/.../....php on line 179 line 179 being the afore mentioned... while($row = mysql_fetch_object($results)) Link to comment https://forums.phpfreaks.com/topic/117589-php-mysql-combine-2-select-querys/#findComment-604962 Share on other sites More sharing options...
akitchin Posted July 31, 2008 Share Posted July 31, 2008 it might be because the syntax of the statement is off: $query2 = "SELECT * FROM Listings WHERE longitude BETWEEN $lonminus AND $lonplus AND latitude BETWEEN $latminus AND $latplus"; give that a whirl. for future reference, invalid result resource usually implies that the query couldn't run due to syntax errors. Link to comment https://forums.phpfreaks.com/topic/117589-php-mysql-combine-2-select-querys/#findComment-605058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.