1
I’m a beginner in programming and I’m trying to find something new, in this case, I have two fields that inform my research values, but I wish the research could be done even if a field is null
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 this case this is query executed
$result_empresas = ("SELECT * FROM clientes
WHERE categoria_id = '$id_categoria' AND subcategoria_id = '$id_sub_categoria'
OR categoria_id = '$id_categoria' AND subcategoria_id = '$id_sub_categoria' IS NULL
OR subcategoria_id = '$id_sub_categoria'
LIMIT $inicio, $qnt_result_pg");
Thank you to all who can help
Even so, I don’t understand why of it, because if it doesn’t matter if anyone is set or null, then because the filter ?
– rbz