hansman Posted August 20, 2008 Share Posted August 20, 2008 I have a Table filled with zip codes. I have another table that i wish to put companies in. In this table there is a field for zip codes. I would like to place several zip codes in this box. I then would like the company profile to come up when i search for one of the zip codes. How can i go upon doing this? Can anyone help? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2008 Share Posted August 20, 2008 Forget about the field for zip codes -- make another table, and make one record per zipcode/company_id pair. Quote Link to comment Share on other sites More sharing options...
revraz Posted August 20, 2008 Share Posted August 20, 2008 Gotta love cross posting http://www.phpfreaks.com/forums/index.php/topic,212817.0.html Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 there are very good triagulation tutorials out there on how to use zip codes. I'll briefly go through the process 1) Get a table called zip_codes it has every zip code, its longitudinal position an latitude position (google it its free) 2) User enters a valid 5 digit zip code and submits a form for a query 3) Run a query to get that zip code's lat/long position 4) Set up your proximity distance and use the conversion 1 arcdegree = 69 miles 5) Requery the zipcode table for all zip codes that have a long/lat thats values satisfy the original zip code +/- the variance (figure in step 4) 6) Use the zip codes in step 5 to query for results in the primary company table. This can almost be done in 1 query. Step 5/6 can be chunked down to 1 query using in the where clause comapny.zipcode in (Select zipcode from `zips` where lat >= lat-off and lat <= lat+off and long >= long-off and long <= long+off) Google it if this makes no sense to you Quote Link to comment 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.