Jump to content

goolge maps api not sorting results


diasansley

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/234264-goolge-maps-api-not-sorting-results/
Share on other sites

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.