944,201 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 532
  • PHP RSS
Oct 23rd, 2009
0

php zip code locate/approximity

Expand Post »
Hello Forum:

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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
williebens is offline Offline
42 posts
since Jan 2008
Oct 23rd, 2009
-1
Re: php zip code locate/approximity
Wasn't this topic discussed about 5 weeks ago on this forum? Have a search. The solution, if I recall used maths (trig) functions.
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 954
Disgraced Poster
ardav is offline Offline
6,730 posts
since Oct 2006
Oct 23rd, 2009
0
Re: php zip code locate/approximity
Click to Expand / Collapse  Quote originally posted by ardav ...
Wasn't this topic discussed about 5 weeks ago on this forum? Have a search. The solution, if I recall used maths (trig) functions.
I did search before posting, but I did not find a solution. I will post my solution when I find it.

Thanks for the suggestion.
Last edited by williebens; Oct 23rd, 2009 at 7:05 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
williebens is offline Offline
42 posts
since Jan 2008
Oct 23rd, 2009
0
Re: php zip code locate/approximity
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 )

edit: You might find this post helpful: http://www.daniweb.com/forums/thread151916.html
Last edited by Ezzaral; Oct 23rd, 2009 at 7:33 pm.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Oct 24th, 2009
0
Re: php zip code locate/approximity
I've done some similar work, there is a lot of code already written. Heres one class already written that may help:
http://www.micahcarrick.com/04-19-20...lculation.html
Reputation Points: 26
Solved Threads: 12
Junior Poster in Training
kylegetson is offline Offline
89 posts
since Sep 2009

This thread is more than three months old

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.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC