Hiya, I'm writing a backend in MySQL with a PHP frontend. One of the PHP
pages searches the database. The user can enter as many or as few fields as
they like. I then search the database using this code:

$result = mysql_query("select * from equipment where (category='$category')
and (description like '$description') and (roomloc='$roomloc') and
(quantity like '$quantity') and (serialno like '$serialno') and (patdue
like '$patdue')",$db);

Messy, I know. The category and roomloc are <option>s and therefore are
definite. However, if the user enters nothing for the other fields, they
get given no results. If I set the default value of each field to % in the
page that calls this, then it works fine. 

It's just not what I'd like to do - have the user clear out % from each
field before putting their data in. Is there an easy way to code "if the
field is blank, send %, else send the users entry" or just putting % before
whatever is sent? (this shouldn't mess up what's being entered, surely?)

Thanks for any help.
-- 
Gary Smith
E: [EMAIL PROTECTED]
W: http://www.l33t-d00d.co.uk
Pics: http://photos.l33t-d00d.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to