Re: Nested IFs Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Jim Moseby" <JMoseby@xxxxxxxxxxxxxxxxx> wrote in message 
news:FEE5CF83F4D3D511860100B0D02204BBD08903@xxxxxxxxxxxxxxxxx
>>
>> 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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux