$where2 = "WHERE "; $where2 .= " value1 = \'".$_POST['val1']."\'"; $where2 .= " AND value2 = \'".$_POST['val2']."\'"; $where2 .= " AND value3 = \'".$_POST['val3']."\'"; $where2 .= " AND value4 = \'".$_POST['val4']."\'";