How to do a search in several fields correctly, given that each field has its own values. I do something like this:
$where = ''; $where .= (!empty($s)) ? " WHERE one ='$s' " : ''; $where .= (!empty($s2)) ? " AND two ='$s2' " : ''; $where .= (!empty($s3)) ? " AND three ='$s3' " : ''; $where .= (!empty($s4)) ? " AND four = '$s4' " : ''; $where .= (!empty($s5)) ? " AND five = '$s5' " : ''; $where .= (!empty($s6)) ? " AND six = '$s6' " : ''; $where .= (!empty($s7)) ? " AND seven = '$s7' " : ''; $sql = "SELECT * FROM invoices $where";
But in this case, the one field should always be filled. And I need to do a search if at least one value out of 7 is filled.