fraser5002 Posted April 6, 2010 Share Posted April 6, 2010 Hi i was wanting to know how i can sort my query based on the latitude value for each record minus a base latitude location and perform a secondry sort doing the same thing on the longitude value which should in theory produce the the array sorted by closest records first to the base lat long i have this code below so farbut as i expected i get errors . I dont know enough about mysql yet too work out how to do what i want // // $query_accommodation="SELECT * FROM `accomodation` WHERE `lat` > ($hill_lat - 0.2) AND `lat` < ($hill_lat +0.2)AND `long` > ($hill_lon- 0.2) AND `long` < ($hill_lon + 0.2)"ORDER BY (`lat`-$hill_lat) ASC,(`long`-$hill_longitude) ASC ; // // where $hill_longitude and $hill_lat are my base lat and long i will be comparing each record in the database too p.s ( if i take out the order by bit this query works fine al be it not sorted) Please help Thanks Quote Link to comment https://forums.phpfreaks.com/topic/197796-help-with-mysql-query/ 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.