Im trying to create a php script that queries a database based on filter input from users
So essentially i want
select * from table where parent_id = '$filter_value'
However i want to apply a default value to $filter_value which will take effect if the user doesnt specify any filters, and will pull up all possible results.
I tried using * but it didnt work…
Two ways:
Compare the value to NULL
Dynamically create the SQL based on whether $filter_value contains a value. If it does not, your query should simply be: