Re: Nested IFs Problem

From: Date: Wed, 31 Aug 2005 20:43:54 +0000
Subject: Re: Nested IFs Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221670@lists.php.net to get a copy of this message
"Jim Moseby" <JMoseby@nrbindustries.com> wrote in message news:FEE5CF83F4D3D511860100B0D02204BBD08903@NRBEXCHANGE-NT... >> >> I have the following nested ifs: >> >> if ($row['date'] < '2005-10-02') { >> if ($row['time'] < '12:00') { >> if ($row['field'] == 'P5' ) { >> >> echo "<td >> class=\"tabletextbluebg\">Success"; >> >> } // This, if there was anything, would be executed if the date and the time condition is true and the field is false >> } // this would be executed if the date condition is true and the time is false, regardless of what the field condition is >> } >> >> else { >> // this would be executed only if the date condition is false, regardless of the other conditions >> echo "<td class=\"tabletextred\">Failed"; >> } >> </td> >> So, you better put all the conditions in a single if, joined by 'and' or &&: if ($row['date'] < '2005-10-02' && $row['time'] < '12:00' && $row['field'] == 'P5' ) { That would do what you want

« previous php.general (#221670) next »