![]() |
Conditional in $this->table->add_row() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Conditional in $this->table->add_row() (/showthread.php?tid=36942) |
Conditional in $this->table->add_row() - El Forum - 12-21-2010 [eluser]skribe[/eluser] Hey folks: New to codeigniter and I haven't coded much in the last 10 years so my aged brain is rusty. Can I drop a longhand conditional into $this->table->add_row()? Code: $this->table->add_row( I'm getting Parse error: syntax error, unexpected T_SWITCH and T_IF errors when using longhand. Shorthand if/else work. If I can't do this can you suggest an alternate solution? Cheers, skribe Conditional in $this->table->add_row() - El Forum - 12-21-2010 [eluser]cahva[/eluser] No, you cant use the longhand version inside that. Just assign those to variables. Its much cleaner that way too: Code: $gender = ($p->gender == 1) ? 'Male' : 'Female'; Conditional in $this->table->add_row() - El Forum - 12-22-2010 [eluser]skribe[/eluser] Thanks, mate. That worked a treat. |