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
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.