I am developing an app that gets a zipcode from a user and then uses that zipcode to find the nearest store locations in miles based on the stores zipcode.
I have a database that has all the zipcodes with there corresponding latitudes and longitudes.
I also have a calculation that computes distance between the zipcodes.
The problem I am facing is that I need the result to be sorted by distance. The issue at hand is that distance is calculated on the fly and how do I sort something that is computed on the fly by a PHp function.
Any help will be highly appreciated.
Zipcode Distance Problem
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
if the distance is calculated inside the sql query, you can "order by" that. If the distance is calculated by php, then you can use usort() or it's sibling functions uasort()/uksort()
each of which uses a user defined comparison function. We talked about it's use very recently if you look through the php-code board.
each of which uses a user defined comparison function. We talked about it's use very recently if you look through the php-code board.