|
Posted by Jerry Stuckle on 09/27/39 11:20
Shelly wrote:
> Does anyone know if there are any modules available that enable searches by
> zipcode for proximity? I want the user to enter a zipcode and then I want
> to somehow search for all entries in a database that are within, say, 25
> miles of that zipcode. This is done in many, many sites on the net and I am
> wondering if anyone knows of an add-on package to make it happen. No sense
> in re-inventing the wheel.
>
> Shelly
>
>
Shelly,
I don't have the code handy - but it's not hard to develop.
Basically store zip codes, longitude and latitude in a database (i.e. MySQL).
Take the long/lat of the entered zipcode. Create minimum and maximum long/lat
for your desired radius (a little searching of the internet will give you the
equations). Then search for any zip code with long/lat within the given range.
Finally, for fine tuning, check the distance of the returned zip code against
the entered zip code (similar formulae).
Last time I did it it was all of about six lines of code and ram in < 1 sec.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|