Jump to content

Zip Codes


hansman

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/120543-zip-codes/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/120543-zip-codes/#findComment-621222
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.