I'm having trouble creating a filter with more than four fields in a normal example where I filter the user's gender so my Query is
<?php
try {
$pdo = new PDO("mysql:dbname=projeto_filtrotabela;host=localhost", "root", "root");
} catch(PDOException $e) {
echo "ERRO: ".$e->getMessage();
}
if(isset($_POST['sexo']) && $_POST['sexo'] != '') {
$sexo = $_POST['sexo'];
$sql = "SELECT * FROM usuarios WHERE sexo = :sexo";
$sql = $pdo->prepare($sql);
$sql->bindValue(":sexo", $sexo);
$sql->execute();
} else {
$sexo = '';
$sql = "SELECT * FROM usuarios";
$sql = $pdo->query($sql);
}
?>
As shown if my variable $ sex is set and is filled then it will filter with what I came by the variable otherwise shows the results without filter more how do I apply more than one filter in the query example I want filtered by sex and also by how do I do this more efficiently?