diasansley Posted April 20, 2011 Share Posted April 20, 2011 hey guys here is my query $sql1 = "SELECT buss_name,buss_desc,buss_video,buss_link,city,zipcode,country,address,tag FROM wp_business WHERE lat BETWEEN $lat - $lat_range AND $lat + $lat_range AND lon BETWEEN $lon - $lon_range AND $lon + $lon_range AND Comp_name ='".$_GET['category']."' order by lat,lon desc LIMIT 0 , 7 "; the query is supposed to do the following 1)find the nearest city from the database the query does that but when im printing the div i am unable to sort the results based on the nearest to the city searched. I have tried orderby and all that stuff but in vain Thanks Quote Link to comment https://forums.phpfreaks.com/topic/234264-goolge-maps-api-not-sorting-results/ Share on other sites More sharing options...
Muddy_Funster Posted April 20, 2011 Share Posted April 20, 2011 can you give an example dataset that comes from runnning your query $sql1 = "SELECT buss_name, buss_desc, buss_video, buss_link, city, zipcode, country, address, tag FROM wp_business WHERE (lat BETWEEN ($lat - $lat_range) AND ($lat + $lat_range)) AND (lon BETWEEN ($lon - $lon_range) AND ($lon + $lon_range)) AND Comp_name ='".$_GET['category']."' order by lat,lon desc LIMIT 7 "; also, if you run it 5 times, is it the same result every time or different? Quote Link to comment https://forums.phpfreaks.com/topic/234264-goolge-maps-api-not-sorting-results/#findComment-1204025 Share on other sites More sharing options...
diasansley Posted April 20, 2011 Author Share Posted April 20, 2011 what ever values i enter the search always shows either ASC or DESC here are some values SELECT id, buss_name, buss_desc, buss_video, buss_link, city, zipcode, country, address, tag FROM wp_business WHERE lat BETWEEN 4.7748161 - 0.21685074885792 AND 4.7748161 + 0.21685074885792 AND lon BETWEEN 51.5748068 - 3.4759198257523 AND 51.5748068 + 3.4759198257523 ORDER BY id LIMIT 0 , 30 i want it to sort dynamically based on which ever city is closer should come first. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/234264-goolge-maps-api-not-sorting-results/#findComment-1204027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.