I think you can't do this with isset(), because if you have a form submitted (via POST I hope), the variables are set even if the hasn't filled out the inputfields.
You need to walk through $_POST and check the value for each key:
reset($_POST);
while (list ($key, $val) = each ($_POST)) {
if($val != '') {
(add values to query) ....
}
}