Yes, it is possible to have an Advanced Search which allows users to fill in one or more fields. Solutions usually involve a series of conditionals which build an SQL statement based on the information submitted by the user.
Assuming you are using MySQL, such a solution might look like this:
- Code: Select all
$where = array();
$where = sprintf("`name` LIKE '%%%s%%'",
$where = sprintf("`description` LIKE '%%%s%%'",
// Repeat for all other fields...
$sql = "SELECT * FROM `table` WHERE " . implode(' OR ',$where) . ";";
As far as efficiency, it depends on how your application is setup. Optimizing the query in PHP before sending it to an SQL database could improve the performance of your application. However, if you are using an existing Stored Procedure in an SQL database to perform the search, it may save you time to optimize the Stored Procedure, rather than mess with PHP.
I hope that helps. Good luck!