I have a question about how to organize this information, I have two selects in my code, that the user chooses the two, generates the table looking for who has the two information, but I would like the search to be done even if the user to select only one of the two fields
This is the request code
if($_SERVER['REQUEST_METHOD']=='POST'){
$id_categoria = $_POST['id_categoria'];
$id_sub_categoria = $_POST['id_sub_categoria'];
$pagina = 1;
$_SESSION['id_categoria'] = $id_categoria;
$_SESSION['id_sub_categoria'] = $id_sub_categoria;
And in case this is query executed
$result_empresas = "SELECT *
FROM clientes
WHERE (categoria_id = '$id_categoria' OR '$id_categoria' IS NULL) AND
( subcategoria_id = '$id_sub_categoria' OR '$id_sub_categoria' IS NULL) AND
('$id_sub_categoria' IS NOT NULL OR '$id_categoria' IS NOT NULL)
LIMIT $inicio, $qnt_result_pg";
Thanks to all who can help.