I have a dropdown <select> list and a button. If I press the button, it will select from a table infos for the value selected from the dropdown list.
I need a way to check in my select query what was the value for the button.
Ex: the dropdown contains
0 <-this is for NULL
1
2
3
All
I need a way to do something like this: 😃 not actually pure SQL 😃
select * from table where field=if(dropdown=0 return null)
if(dropdown=All return 1, 2, 3, 4)
I hope you understand.
I need to do this in SELECT because i will have plenty of dropdowns in my form.
I was thinking also to check the variables in PHP, build the actual query string before the select query, something like this....
$string='';
if (dropdown>=1)&&(dropdown<=4) $string=$string.'AND field=$dropdown';
else $string=$string.'AND field>=1 and Field<=4';
.....
.....
and then the query.
This would work but I am convinced that this is not the best way.