Given this query
$query = "SELECT * FROM products WHERE category = {category} AND price = '{price}'"
with these $_GET params: category = 10 and price = $60
I want to replace the content inside the {} with the actual GET values to get a sql query like this one:
"SELECT * FROM products WHERE category = 10 AND price = '$60'"
but if one or more or the parameters are missing i want to replace the content of the {} with something different to avoid the execution. for example:
"SELECT * FROM products WHERE category = category AND price = price"
note: I know about sql injection. that is a different subject. what i want to know if how to avoid the execution of a sql stamente if the value (from get) is not present. for example select * from products where id = id returns all the products but select * from products where id = 100 returns only one (with id 100)