poleposters Posted March 23, 2008 Share Posted March 23, 2008 Hi, I'm building a business directory and want to include a search function so that when a zip code is entered results are returned for the zipcode and all the neighbouring zip codes. I know its possible to use latitude and longtitude to create a radius search, however I only want to return results from zip codes which share a common border with the input zip. I have been supplied some sample zipcode data from a mapping company. The full database is quite expensive, so I'd like to make sure I can actually use the information before I shell out for it. Below are a few rows of sample data. The first field is the zip code, the second is the number of adjoining zip codes and the remainder is the neighbouring zip codes 2000,5,2007,2008,2009,2010,2011 2006,4,2008,2037,2042,2050 2007,4,2000,2008,2009,2037 2008,8,2000,2006,2007,2010,2016,2037,2042,2043 2009,3,2000,2007,2037 2010,6,2000,2008,2011,2016,2021,2027 I'm pretty lost on this one. If anyone has any ideas on how to setup the tables and perform the queries that would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/97449-neighbouring-zip-code-database-search/ Share on other sites More sharing options...
cmgmyr Posted March 23, 2008 Share Posted March 23, 2008 Check this out, it should do everything you want it to do. http://www.micahcarrick.com/04-19-2005/php-zip-code-range-and-distance-calculation.html Quote Link to comment https://forums.phpfreaks.com/topic/97449-neighbouring-zip-code-database-search/#findComment-498605 Share on other sites More sharing options...
poleposters Posted March 23, 2008 Author Share Posted March 23, 2008 Thanks cmgmyr, The script is the best example I've seen using lat/long. But the only data I can obtain cheaply for Australian zipcodes is using the table above with the search zip, number of adjoining zips and the other adjoining zips. The main problem I'm having with understanding how to set up the queries is that some zipcodes have three neighbours while other have anything up to ten neighbours, which means I'm going to have blank fields in my table. Any ideas on how to set up the tables? Quote Link to comment https://forums.phpfreaks.com/topic/97449-neighbouring-zip-code-database-search/#findComment-498833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.