Welcome Guest, Not a member yet? Register   Sign In
Conditional in $this->table->add_row()
#1

[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(
                      if($p->gender=='1')
                      {'Male'} else {'Female'},

                      switch($p->age) {
                          case 0:
                             '17 and younger';
                             break;
                          case 1:
                             '18-25';
                              break;
                          default:
                              'Old Fart';
                      }
);

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


Messages In This Thread
Conditional in $this->table->add_row() - by El Forum - 12-21-2010, 12:26 AM
Conditional in $this->table->add_row() - by El Forum - 12-21-2010, 05:40 AM
Conditional in $this->table->add_row() - by El Forum - 12-22-2010, 02:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB