You are here: Re: [PHP] Nested IFs Problem « PHP « IT news, forums, messages
Re: [PHP] Nested IFs Problem

Posted by "Satyam" on 10/11/34 11:25

"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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация