Page 1 of 1
postalcode search
Posted: Tue Sep 19, 2006 7:55 am
by hame22
Hi,
I was wondering if there is a way/tool in PHP which can be used to do searches involving postal codes.
e.g. I have a directory of users and would like to search for users close to an entered postal code
in php is there an easy way to achieve this?
Thanks in advance
Posted: Tue Sep 19, 2006 7:56 am
by patrikG
You be wanting to use thar webservice on
http://www.geonames.org/ - it be a REST-query, yar.
Posted: Tue Sep 19, 2006 8:26 am
by happy_tapper
Supposing you have a list of users and their post codes in a table, you could submit a query searching for all users where the post code is like whatever is entered.
eg
Insert code for user to input search query, then something like :
Code: Select all
$result = mysql_query ("SELECT users FROM database WHERE postalcode LIKE '%$input%' ");
Then display your results in a table.
Posted: Tue Sep 19, 2006 11:03 am
by RobertGonzalez
Is this for proximity searching (all users within X miles of some_zip) or for straight searching on the postal code?
Posted: Tue Sep 19, 2006 11:57 pm
by Skeptical
You will need to purchase or download a zip code database. Within the database, it will contain the exact GPS coordinates of a particular zip code. You will then be able to perform proximity searches using trig functions. It's as simple as that.
Search the net for zip code databases. Many companies sell it. I believe there are free ones as well, but they won't be up-to-date.
Posted: Wed Sep 20, 2006 2:55 am
by CoderGoblin
Once you have Lat/Long distance for postcodes you need not just Trig Functions but "Great Circle Distance" formulas. A search using google should give more information.
I also found
GeoClass PHP useful.
Posted: Wed Sep 20, 2006 10:06 am
by Luke
also... google maps has a really cool geocoder...
AJAX
Standard HTTP
Posted: Wed Sep 20, 2006 10:23 am
by RobertGonzalez
Search these forums for Zip Code. Burrito mentioned a great link a few weeks back.