Tailor your query to the request of your user(s). I.e. if only one parameter was passed from the form only match against one field.
E.g.: $sql = "SELECT ID, publication,run_date,left(ad_copy,40) as Advertisement FROM classifieds WHERE MATCH "; if ($param1) $sql .= "(ad_copy) against ('$param1')"; if ($param1 && $param2) $sql .= " AND MATCH "; if ($param2) $sql .= "(long_group) against ('$param2')"; /* query */ -----Original Message----- From: Kim Kohen [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 10:47 PM To: <[EMAIL PROTECTED]> Subject: Trapping for no user input in a query Hello all I am trying to query two columns in mysql which have fulltext indexes using the following: SELECT ID,publication,run_date,left(ad_copy,40) as Advertisement FROM classifieds WHERE MATCH (long_group) against ('\"$param2\"') AND MATCH (ad_copy) against ('\"$param1\"') As you can probably guess, the $params are coming from a form via php. The above query works fine when the user submits both parameters but I can't work out how to trap for the user only entering a single parameter (which causes the query to always return an empty set)? Cheers and thanks kim --------------------------------------------------------------------- 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