Hi

$query = 'SELECT *
                  FROM Table
                  WHERE
          FirstName LIKE "%'.$firstname.'%"' ;
          if($lastname)$query.= ', AND LastName LIKE "%'.$lastname.'%"';
          if($region)$query.= ', AND Region LIKE "%'.$region.'%"';
          if($loan_officer)$query.= ', AND Loan_officer LIKE
"%'.$loan_officer.'%"';
etc.....

        $mysql_result = mysql_query($query, $mysql_link);

HTH

Peter

-----------------------------------------------
Excellence in internet and open source software
-----------------------------------------------
Sunmaia
www.sunmaia.net
[EMAIL PROTECTED]
tel. 0121-242-1473
-----------------------------------------------

> -----Original Message-----
> From: Mark Stringham [mailto:[EMAIL PROTECTED]]
> Sent: 28 March 2002 17:21
> To: MySQL
> Subject: SQL query question - using LIKE
>
>
> I have a  simple search form that allows the user to search a contact db
> based on criteria that they choose.
> Search by -
> first name - text box
> last name - text box
> region - drop down
> loan officer - drop down
>
> I want the user to be able to receive results if they choose all possible
> criteria or just one criteria.
> My question is about query structure.  How do I query the database when I
> have multiple criteria selected?
>
>
> Any help is appreciated.
>
> Mark
>
>
> ---------------------------------------------------------------------
> 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