At this point, I'm merely numerically comparing the user's zipcode to each one in the database and determining whether to return or discard each record. Is there a better way to do this?
Probably. This sounds like you are using a flat file 'data base' and simply iterating from the beginning of this to the end. For a small file this works fine but breaks down when you get bigger and or demand on access to this file becomes high. On way to arrange this in a proper database would be to have two tables:
Zip Table Zip Code,Distrubitor Code/s 71000, 1|2|3 72000, 3|4 .... Distributor Table Dist ID, Lotsa other Data :-) 1, She'll be right INC 2, No Worries Mate INC 3, Can Do Corp 4, The Impossible Done Yesterday P/L
You do the lookup on the Zip table (really basic SQL) to get the Dist ID(s) for that area (Pipe delimited here). You then grab all those Distributors from the Dist table. Presumbaly the Distributor ID table should already exist? So you just need to generate a Zip table that cross references the Zip code to the Dist ID. You could do this manually using a map or automate it using the zip code geographic position data mentioned elsewhere. You would probable need to get geographic co-ordinates for you distributors but this is pretty easy. You can get the longs and lats for any US city from many of the online mapping services free. See jcwren monk map page (on the stats pages) for one such link.
You could implement this using DBI and DBD::CSV making it easy to move to a real database in the future.
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Zipcode search engine
by tachyon
in thread Zipcode search engine
by Jerry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |