I want to find all listings within an arbitrary radius of a ZIP code. e.g. 10 miles from 90210, 100 miles from 00603, etc.
If my query is "10 miles from 90210", I want to return all the listings that are within this 10-mile radius. The listings are also ZIP codes, so I essentially want to find all the other ZIP codes within this 10-mile radius.
I think once I have collected all the ZIP codes in the radius, then I add them into an array, and then use SQL to find all listings that have the ZIP codes in this array. However, I am not sure if this is the best way it's done.
I have tried to do research, but it gets very complex for me; I think it may have something to do with a Great Circle. I have been looking into the Aviation formulas too at http://williams.best.vwh.net/avform.htm, but still can't work anything out.
I have a database of ZIP codes containing the longitude and latitude of all ZIP codes, along with city and state info. This is enough info for what I need. I guess I just need to know the math; I don't want to use an API.
I am absolutely lost here, on how I go about calculating such radii.