vbted
03-03-2005, 07:02 PM
OK, this works for me but if no match is found in the four fields I get an error. I would like $formpmid to equal "1" if no match is found. any help would be great. I'm ob a sql noob. -Ted
Any other comments on the code would be great also.
////////////////////////////////////////////////
if ($normalanswer1 == ''){
$formpmid = "1"; }
else {
$result = $DB_site->query("SELECT userid
FROM " . TABLE_PREFIX . "userfield
WHERE (field19 = '$normalanswer1') OR (field26 = '$normalanswer1') OR (field15 = '$normalanswer1') OR (field25 = '$normalanswer1')");
while ($usersid = $DB_site->fetch_array($result))
{
$formpmid = $usersid['userid'];
}
}
//////////////////////////////////////////////////
Any other comments on the code would be great also.
////////////////////////////////////////////////
if ($normalanswer1 == ''){
$formpmid = "1"; }
else {
$result = $DB_site->query("SELECT userid
FROM " . TABLE_PREFIX . "userfield
WHERE (field19 = '$normalanswer1') OR (field26 = '$normalanswer1') OR (field15 = '$normalanswer1') OR (field25 = '$normalanswer1')");
while ($usersid = $DB_site->fetch_array($result))
{
$formpmid = $usersid['userid'];
}
}
//////////////////////////////////////////////////