I know for example if you KNOW what parameters to expect you can simply use
$_GET['parameter']
in your MYSQL query. What if you expect 4-5 parameters, however maybe NOT all of them are passed? For example, let’s say the user wants to list all the products which have a price more than 20$ and a warranty of 2 years.
The user could have more search options like for example, the product category should be 2 which is for Laptops
now, my question is, should I have many if statements and check for each possible parameter to see if they are set, and if they are then include them in my MYSQL query, or is there a faster way?
thanks in advance
you should try foreach. Something like:
you can uset he str_where string to filter the products.