| | |
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.
•
•
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 |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu method mlm mod_rewrite multiple mysql oop pageing pagerank parse paypal pdf php printer problem query radio random recursion recursiveloop regex remote script search server sessions sms soap source space sql structure subversion support! syntax system table template tutorial update upload url validation validator variable video web xml youtube






