nested ifs?

From: Date: Fri, 20 Apr 2001 14:49:01 +0000
Subject: nested ifs?
Groups: php.db 
Request: Send a blank email to php-db+get-8747@lists.php.net to get a copy of this message
Before I delete something from the database, I need to make sure that there is only one entry, and not multiple ones. I can't do this via the database itself, because of the need for multiple entries that bear different names, but the same primary key (which I have since removed). I can't add names as a part of the primary key-- they're used often because someone will order multiple necessities on the same days and with the same order number. Here's the problem.... since I'm forced into doing this in code, how do I make a nested if that works or is it even possible??? This is the code that I have so far (please note, it is within a function)... any ideas of how I can make it work? $not_del = "SELECT FROM Orders WHERE req like '" . $GLOBALS["old_req"] . "' AND source like '" . $GLOBALS["old_src"] . "' AND number = " . $GLOBALS["old_num"]; $del = "DELETE FROM Orders WHERE req like '" . $GLOBALS["old_req"] . "' AND source like '" . $GLOBALS["old_src"] . "' AND number = " . $GLOBALS["old_num"]; if (mysql_num_rows($not_del) != 1) {
    $message .= "Multiple entries.  Delete NOT allowed.";
} elseif (mysql_num_rows($not_del) == 1) {
    if (mysql_query($del)) {
      $message .= "Remove OK.";
    } else {
      $message .= "Remove NOT.";
    }
} return urlencode($message); Thanks, Liz

« previous php.db (#8747) next »