IF statement problems
| From: | Paul Hawkins | Date: | Mon, 31 Jul 2000 18:36:45 +0000 |
| Subject: | IF statement problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-9227@lists.php.net to get a copy of this message | ||
I'm having a bit of trouble with an if statement generated from a few
pull-down menus on a form. The two pull-downs set the variables $vname and
$div. Based on the combination of their values I need to set a separate
variable $value. The following IF statement works fine until I include the
last if statement. IF the last IF statement is in the script it gets
evaluated as true no matter what is selected on the form.
Here is the code:
if ($choice) {
if (($vname==1) AND ($div==1)) {
$value=1;
}
if (($vname==1) AND ($div!=1)) {
$value=2;
}
if (($vname!=1) AND ($div==1)) {
$value=3;
}
if (($vname!=1) AND ($div!=2)) { //bad if statement
$value=4
}
}
Thanks,
Paul Hawkins