You need to build the SQL on the fly, based on the information that is passed.
As an example, let's say you have a form where an HR manager can choose people from a database based on their title, department, and office location (in a very big company, of course).
If the user chooses a specific title (manager) and department (IT), but leaves office location to the option "choose an office," then you would build your SQL statement to read:
SELECT firstname, lastname, title, department
FROM users,departments
WHERE users.deptID = departments.ID
AND department = 'IT'
AND title = 'manager'
ORDER BY lastname
How you build the SQL is up to you, but it should be fairly straightforward in the PHP code. Then simply apply the SQL against your database, and you should get the right result set.