You're getting all new boats + all sail boats + all boats of type x because you're using ORs. If you only want records that match all the criteria, use ANDs instead.
SELECT * FROM boat WHERE condition='$condition' AND type='$type'
Or you might try
SELECT * FROM boat WHERE (condition='new' OR condition='used') AND type='sail'
You probably don't need to use LIKE since the form fields will always supply you with the same values.
-bill
web-dev wrote:
Hello,
I am attempting to search a table based on information passed from a submitted form.
The form contains details as follows:
(radio buttons)
Condition: O new O used
Type: O power O sail
(textbox)
Make: [ ]
etc. etc. etc. ( it's a long list!)
If I write a query ie.
Select from boat where condition like '$condition' or type like '$type' or make like '$make' etc......
I get a search result that includes boats with any of the criteria that match one of the like comparisons,
ie.returns all new boats + all sail boats + all boats of type X
which makes sense
What I really want is a result that is limited to a group of boats that individually match the submitted criteria but excludes the boats outside the set ie. returns only boats which are new, sail, type X boats.
If anyone can help me with sage advice on how to go about achieving this end, I would be highly grateful. I am stuck and may be missing something simple, or maybe there is more to what I am attempting than a simple query. Either way, pointers, tips, sample queries would be helpful and appreciated.
Kris O.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php