I have a database of adverts which are searched and displayed using PHP. A user inputs their postcode during the search and then the query is executed. When the results page is returned to the user it displays the distance the advert item is from their postcode.
What I need to know is how to order the result by distance. I can order the results for price by placing a sort on the query, but because the distance is calculated on the php page and is different for each user I don't know how to order it.
The distance is calculated using grids and Pythagoras theorem.
Not sure what code would be useful. If you want to see any just let me know.
Thanks