Just build the SQL statement with IFs...
sql = "SELECT * FROM table WHERE ";
if ($SearchByName) $sql .= "name = $Name AND ";
if ($SearchBySurname) $sql .= "surname = $Surname AND ";
if ($SearchByCompany) $sql .= "company = $Company AND ";
...
then just remove the last four characters, and perform the query...
Siggy
----- Original Message -----
From: "Don Smith" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 18, 2001 3:56 PM
Subject: [PHP-DB] Best Way
> I've searched the manual and read many examples, but I have to ask here
for
> the best way to program for a number of possibilities. I've got my site
> working the hard way, but I'll bet there's a smarter way of doing the
> following:
>
> Visitors to my site can search my database by lastname and/or firstname
> and/or company. Is there a succinct way to checking for all possible
> combinations? I alreay have NONE SELECTED covered, but the rest of the
> possibilities are spotty. Too many IF statements, youknowwhaddimeanverne?
>
> SO... the user might just enter the last name, or just the first name, or
> just the first and last, or just the company or just the last name and the
> company.. and, oh well, you get the idea. Am I stuck with an awful lot of
IF
> statements or is there a smarter way of handling this? The site is
> CameraCrews.com. Select "-by Name" to see the input page.
>
> Thanks for any help,
> Don Smith
> NewsVideo.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]