You have it right. But if the user searches for new power boats, and doesn't specify a make, make should not appear in your WHERE clause. The query has to be different depending on the criteria that have been chosen (or not chosen, as the case may be). Prior to executing the query, look at all the form fields you've gotten and ignore the ones that don't have a value attached to them.

-bill



web-dev wrote:

Bill Lovett wrote:

Hello,

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.

If I use AND, wouldn't all conditions need to be true to return a result? In the case of the search form as constructed, the user can select or enter search criteria information in from one to all of the available search criteria. Using the truncated criteria list as an example, if the user selected 1)new 2) power boats and left the 3) make text box empty, AND, and the whole query, fails because the WHERE make like '$make' condition returns false, I think. Please correct me if I'm wrong! I want and need to understand this..



---------------------------------------------------------------------
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

Reply via email to