puoi fare così:
Codice PHP:
$query = "select * from db where (";
if (!empty($_POST['a']))
$query = $query."a=".$_POST["a"]." and ";
if (!empty($_POST['b']))
$query = $query."b=".$_POST["b"]." and ";
if (!empty($_POST['c']))
$query = $query."c=".$_POST["c"]." and ";
if (!empty($_POST['d']))
$query = $query."a=".$_POST["d"]." and ";
if (!empty($_POST['e']))
$query = $query."e=".$_POST["e"]." and ";
$query = substr($query, 0, strlen($query)-5).')';