php zip code locate/approximity

Reply

Join Date: Jan 2008
Posts: 40
Reputation: williebens is an unknown quantity at this point 
Solved Threads: 0
williebens williebens is offline Offline
Light Poster

php zip code locate/approximity

 
0
  #1
Oct 23rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,102
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 139
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster
 
-1
  #2
Oct 23rd, 2009
Wasn't this topic discussed about 5 weeks ago on this forum? Have a search. The solution, if I recall used maths (trig) functions.
If you don't reply to your own thread or you can't find the solved link - you're off my Christmas list - permanently! Bah humbug!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 40
Reputation: williebens is an unknown quantity at this point 
Solved Threads: 0
williebens williebens is offline Offline
Light Poster
 
0
  #3
Oct 23rd, 2009
Originally Posted by ardav View Post
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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,515
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 523
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster
 
0
  #4
Oct 23rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 62
Reputation: kylegetson is an unknown quantity at this point 
Solved Threads: 9
kylegetson's Avatar
kylegetson kylegetson is offline Offline
Junior Poster in Training
 
0
  #5
Oct 24th, 2009
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
Don't pay data charges. txtFeeder.com is a free way to read the web on your mobile, and avoid data charges! **Now txtFeeder has a wireless note feature! Make notes on the go!
-Kyle Getson
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 274 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC