I'm assuming you're using PHP... this example is rather simplistic; you can
create a whole routine for building a select statment.  You could have a
checkbox on the form that allows for AND/OR comparison (the name on the form
would be 'operator' in this example):

$query = "select * from $database where title like '%$title ";
if(!empty($quotation))
    $query .= " $operator quotation like '%$quotation%'";



----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 03, 2001 3:33 AM
Subject: Query with multiple form fields


> The following query
>
> SELECT * from $database WHERE title LIKE '%$title%' OR quotation LIKE
'%$quotation%'
>
> does not work as desired, if one of the two query fields in the HTML form
stays empty. How do I do this query properly, leaving the user the
opportunity to narrow the search by filling in as many fields as he wishes,
e. g. "list all books with THIS word in the title and/or THAT word in the
quotation".
>
> ---------------------------------------------------------------------
> 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

Reply via email to