I'm doing a very simple filtering system using PHP
and mysql
.
$stmt = $conexao->prepare("select * from filme where genero = '$genero'");
I'm wanting to put one in the genre list which, when selected, displays all the movies.
I know I could do this easily using if / else:
if ($genero == "todos"){
$stmt = $conexao->prepare("select * from filme");
}else{
$stmt = $conexao->prepare("select * from filme where genero = '$genero'");
}
But I wanted to know if you have any other way to do this if the system gets much more complex and if / else gets too big. For example, if you wanted to filter the movies also by year of release, director and indicative rating, all at the same time and with the same option of displaying all.
How could I do this?
Thanks in advance for the answers.