Re: zip code locator problems
| From: | Michael Kimsal | Date: | Tue, 28 Nov 2000 23:48:12 +0000 |
| Subject: | Re: zip code locator problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27705@lists.php.net to get a copy of this message | ||
Any particular reason you're searching for dealers by a
sequence of ZIPs rather than by geographic distance?
I'm in 48197. 48198 is close, but 48201 is pretty
far away. 48109 is much closer.
Maybe if you added 100000 to the zip, then added 10,
then subtracted 100000 you'd get what you needed.
01951
would be
101951 + 10 =
101961 - 100000 = 01961
But is 01961 anywhere close to 01951 for a 'dealer locator' ?
Tom Beidler wrote:
> I have a dealer locator that attempts to find dealers thru a range of zip
> codes. The end user enters a zip, two variables are created $high=$zip+10
> and $low=zip-10 and then runs the following query on a MySQL database;
>
> $query = "SELECT name, bill_address1, bill_address2, bill_city, bill_state,
> bill_zip, phone, email from dealer WHERE bill_country = 'USA' AND (zip <=
> '$high' AND bill_zip > '$low') ORDER BY name";
> $result = mysql_query ($query)
> or die ("Cannot execute query");
>
> Everything works fine except for zips with a 0 preceeding, ie 01095 finds
> 10951 and 11021.
>
> Obvious issues include the zip column in the MySQL database is a varchar and
> not an int. I did that to accomidate for hyphenated zip codes, ie.
> 44012-0987.
>
> I can I fix this?
>
> Any help is greatly appreciated,
> Tom
>
> >>.>>.>>>.>>>>>.>>>>>>>>>
> Tom Beidler
> Orbit Tech Services
> 805.455.7119 (cell)
> 805.682.8972 (phone)
> 805.682.5833 (fax)
> tbeidler@mindspring.com
> >>.>>.>>>.>>>>>.>>>>>>>>>
>
--
==========================
Michael Kimsal
http://www.phphelpdesk.com/search/
PHP Training courses
http://www.tapinternet.com/php