Execute($query)){ throw new Exception("Couldn't get question '$field' answer
".$connect->ErrorMsg()); //Checked } $row = $result->fetchRow(); $hits = 0; while($e = each($row)) if(stripos($e['key'], $field) !== false) // we're checking only fields containing answer to our question if(($e['value'] !== "")) // increase hits if user answered that question ++$hits; if($hits >= $min && $hits <= $max) return $valueForTrue; else return $valueForFalse; } }