Codice PHP:$condizione = false;
$where = " WHERE ";
if($nome != "") {
$where .= "nome = '".$nome."' AND ";
$condizione = true;
}
if($cognome != "") {
$where .= "cognome = '".$cognome."' AND ";
$condizione = true;
}
if($indirizzo != "") {
$where .= "indirizzo = '".$indirizzo."' AND ";
$condizione = true;
}
if($cap != "") {
$where .= "cap = '".$cap."' AND ";
$condizione = true;
}
if($data != "") {
$where .= "data = '".$data."' AND ";
$condizione = true;
}
if($condizione == true) {
$where = substr($where,0,-5);
$query = "SELECT * FROM lettura ".$where;
}

Rispondi quotando