I am trying to write a php script that will take as input a zip code and output the zip code with its respective city and state with the name of any companies/businesses in that zip code. Ok, I got this part working. The other part is that if the user enters a zip code that either does not exist or there is no businesses in that zip code, then the output would be a range of zip codes within, let us say, 5 miles from the zip code the user entered. I have a database with all the zip codes, latitude, longitude, city, and state columns.
Is there anyone who can help me code this in php? Thanks.
--Willie
Last edited by williebens; Oct 23rd, 2009 at 6:42 pm.
There are plenty of references on calculating the distance between two coordinates, but since you're only interested in an approximate 5 mile radius, you could just use the Pythagorean theorem and assume the curvature is negligible dist = sqrt( (x2-x1)^2 + (y2-y1)^2 )
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.