CodeIgniter Forums
comparison condition is not true - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: comparison condition is not true (/thread-18976.html)



comparison condition is not true - El Forum - 05-24-2009

[eluser]alberta[/eluser]
hello,

I am using parse. On view page i've this code.

Code:
<?php
     if( ('{status}' == 'Active') || ('{status}' == 'Inactive')) { ?>
     <td><a href='projects/change_status/{status}/{id}'>{status}</a></td>
        &lt;?php } else {?&gt;
    <td>{status}</td>
    &lt;?php } ?&gt;

but it always goes to else part even status is Active or Inactive Sad

Kindly guide me What's wrong with this code?
Thanks in advance


comparison condition is not true - El Forum - 05-24-2009

[eluser]Wuushu[/eluser]
Code:
&lt;?php
     if( ({status} == 'Active') || ({status} == 'Inactive')) { ?&gt;
     <td><a href='projects/change_status/{status}/{id}'>{status}</a></td>
        &lt;?php } else {?&gt;
    <td>{status}</td>
    &lt;?php } ?&gt;

Does that work better?


comparison condition is not true - El Forum - 05-24-2009

[eluser]tomcode[/eluser]
Would be surprised that Your solutions work, so here's my take :

Code:
&lt;?php

     if( $status == 'Active' || $status == 'Inactive' ) :

?&gt;
     <td><a href='projects/change_status/{status}/{id}'>{status}</a></td>
&lt;?php

     else :

?&gt;
    <td>{status}</td>

&lt;?php

     endif;

?&gt;



comparison condition is not true - El Forum - 05-24-2009

[eluser]alberta[/eluser]
Hey I have tried both of the code suggested by you people. But both r not working. As i'd told em using parser so it is showing me value when i write '{status}' instead of $status or {status}. I have echoed the values and it is showing exact value when i write '{$status}' but inspite of this it goes to else part. I dont know what's wrong with it Sad


comparison condition is not true - El Forum - 05-24-2009

[eluser]tomcode[/eluser]
Is the PHP parsed ?


comparison condition is not true - El Forum - 05-24-2009

[eluser]alberta[/eluser]
what i meant by parser was that I am using template parser

http://ellislab.com/codeigniter/user-guide/libraries/parser.html

and for that i would have to wirte '{status}'


comparison condition is not true - El Forum - 05-25-2009

[eluser]alberta[/eluser]
Can some one tell me how i can put this if conditon alongwith template parser. As i've written code above. I have searched a lot but found no solution Sad this template parser is really creating problems for me.

Any help would be appreciated