How would I implement a search in which there could be multiple inputs to search against?
For example i have a client database which i need to search, the search form has 2 inputs FirstName and Surname.
If the FirstName is populated and the Surname is not populated my search would be:
If the Surname is populated and FirstName is not populated my serach would be:Code:SELECT CustID FROM customers WHERE FirstName='$FirstName'
If both fields are populated the serach would be:Code:SELECT CustID FROM customers WHERE Surname='$Surname'
How would this be implemented?? Do I need to create a search for each possible situation and then control which one is used by an if statement - i'm guessing not as that would very long winded for a longer example such as searching by address which may have 5 or more input fields, any of which may be populated.Code:SELECT CustID FROM customers WHERE FirstName='$FirstName' AND Surname='$Surname'
If its relevant i'm using PHP also
Thanks
James




Bookmarks