Re: if ... else ...

From: Date: Fri, 26 Jan 2001 23:03:50 +0000
Subject: Re: if ... else ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36911@lists.php.net to get a copy of this message
I'm not sure if I'm understanding correctly, but you might take a look at this modification... Notice: all lines with a > in front of them have remained unchanged. Lines that can safely be deleted are preceeded by single-line comments (//), and lines without a > are newly added lines. $allFieldsFilled = true; // assume this is true until we prove it to be false (all it takes is once!) for ($i=1; $i<=5; $i++) { if ($row["num$i"] == '') { printf ("You have to goto Scene$i<p>"); $allFieldsFilled = false; // something hasn't been filled yet } // if } // for if ($allFieldsFilled) { printf ("You don't have anything to fill<p>"); } // if Intention: loops through all fields, printing "You have to goto Scene$i" for each field that is empty. However, if no fields are empty, "You have to goto..." should never be printed and "You don't have anything to fill" should instead. I could've read your problem wrong, too, though. Good luck. --Toby --Toby

« previous php.general (#36911) next »