Re: If else question
| From: | Miguel Cruz | Date: | Tue, 23 Apr 2002 16:18:34 +0000 |
| Subject: | Re: If else question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94190@lists.php.net to get a copy of this message | ||
On Tue, 23 Apr 2002, Jennifer Downey wrote:
> I am wondering. When you use an if else statement and a condition exists
> isn't the if part suppose to stop?
> Then if the condition doesn't exist it is suppose to do something else?
>
> I am wondering because I have a form that goes something like this.
>
> select such and such from the table
> if that condition < 1
> echo that it can't be found
> else
> echo the form
>
> But in this case even if the condition < 1 it still echoes the form.
> I am not understanding this.
If and else expect to be followed by exactly 1 statement. To aggregate
multiple statements as one, surround them with {curly braces}. I'm
guessing you didn't do that, and you're seeing the execution of all but
the first of the statements following the else.
So it should be:
if ($var<1)
echo "can't be found";
else
{
echo "first line of form";
echo "second line of form";
}
miguel