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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to