On Tue, 30 Nov 2004 09:22:11 -0800 (PST), Stuart Felenstein <stuart4m@xxxxxxxxx> wrote: > I'm building a search form where users can search for > people by zip code. Trying to get an opinion here. > Well maybe more then just one. > > Should I have seperate textfields, say (arbitrary) 3 , > where they can put in 1 zip code per field. Or do I > do it with one text field , using delimited entries - > > i.e 20199, 20294, 20599, 20054 > > Or the one text field with boolean. > > i.e 20199 AND 20294 OR 20599 You can never count on the user to enter data as you would like it. I'd play it safe and go with seperate fields. Of course you always check the data with javascript to make sure it's formed the way you want either way you go. It'll help some, but as you probably already know javascript can't be relied on 100% for data validation. > I'm thinking boolean is the best, but being the > inexperienced lame brain I am , how difficult will it > be ? > > by the way, this will be seraching a database field(s) I don't know if you know much about zip codes, but when using them to search a database you might want to just use the first 2-3 digits and a wildcard, especially if you want to search wide areas and such. To search for multiple zip codes you probably want to go with a LIKE query and use OR. $sql = " SELECT * FROM people WHERE 1 AND ( zip LIKE '202%' OR zip LIKE '202%' OR zip LIKE '205%' ) "; I'd do it this way because you can build the part after the AND with simple array iteration and PHP's implode(). $array = array(); foreach( $_POST['zip'] as $v ) { $array[] = " zip LIKE '" . $v . "%' "; } $OR = implode( ' OR ', $array ); $sql = " SELECT * FROM people WHERE 1 AND ( $OR ) "; All untested of course. > Alright I await the wisdom of PHP-General :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php