Codice PHP:
if ($_POST['campo1'] != "") {
$where = "campo1='".$_POST['campo1']."'";
}
if ($_POST['campo2'] != "") {
$where .= ($where == "") ? "campo2='".$_POST['campo2']."'" : " AND campo2='".$_POST['campo2']."'";
}
if ($_POST['campo3'] != "") {
$where .= ($where == "") ? "campo3='".$_POST['campo3']."'" : " AND campo3='".$_POST['campo3']."'";
}
mysql_query("SELECT * FROM tabella WHERE ".$where);