Re: IF statement problems
| From: | Mark A Mucha | Date: | Mon, 31 Jul 2000 18:56:43 +0000 |
| Subject: | Re: IF statement problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9235@lists.php.net to get a copy of this message | ||
If the $vname value is 2 and the $div val is 1, both if statements will
execute.
Maybe you should run it like
if(condition){
}
else if(condition){
}
else if(condition){
}
of make it alittle easier with a switch statement.
if (($vname!=1) AND ($div==1)) {
$value=3;
}
if (($vname!=1) AND ($div!=2)) { //bad if statement
$value=4;
}
"Paul Hawkins" <phawkins@californiasteel.com> wrote in message
news:98F28C22172ED411A076000629A821330593E9@srvr2.californiasteel.com...
> Sorry about that, yes in the example I gave I'm missing the semicolon.
But
> in the script it is there.
>
> Thanks,
>
> -Paul
>
> -----Original Message-----
> From: Sam Masiello [mailto:smasiello@chekinc.com]
> Sent: Monday, July 31, 2000 11:42 AM
> To: Paul Hawkins; php-general@lists.php.net
> Subject: RE: [PHP] IF statement problems
>
>
>
> You are missing a semicolon after $value=4
>
> HTH
>
> Sam Masiello
> System Analyst
> Chek.Com
> (716) 853-1362 x289
> smasiello@chekinc.com
>
> -----Original Message-----
> From: Paul Hawkins [mailto:phawkins@californiasteel.com]
> Sent: Monday, July 31, 2000 2:37 PM
> To: php-general@lists.php.net
> Subject: [PHP] IF statement problems
>
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>