| | |
php zip code locate/approximity
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 40
Reputation:
Solved Threads: 0
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
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.
-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.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Jan 2008
Posts: 40
Reputation:
Solved Threads: 0
0
#3 Oct 23rd, 2009
Last edited by williebens; Oct 23rd, 2009 at 7:05 pm.
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
edit: You might find this post helpful: http://www.daniweb.com/forums/thread151916.html
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.
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
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
-Kyle Getson
![]() |
Similar Threads
- Safari Zip Code Problem (OS X)
- United States Zip Code! Block Island, Rhode Island - 02807.com (Domain Names for Sale)
- Taking offers on 33323.com! Ft. Lauderdale, Florida Zip Code (Domain Names for Sale)
- Php Mysql : Code for Multiple Field Search (PHP)
- Problem with PHP Search Code.... (PHP)
- Real Time Gas Prices For ANY us zip code! (Websites for Sale)
- How can insert PHP snip code into a php website (PHP)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp check checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript job joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search server sessions smarty sms sorting source space sql startup stored syntax system table traffic tutorial unicode update upload url validator variable video web youtube zend






