zip code locator problems

From: Date: Tue, 28 Nov 2000 23:28:12 +0000
Subject: zip code locator problems
Groups: php.general 
Request: Send a blank email to php-general+get-27701@lists.php.net to get a copy of this message
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 >>.>>.>>>.>>>>>.>>>>>>>>>

« previous php.general (#27701) next »