Welcome Guest, Not a member yet? Register   Sign In
add_row with array from query result
#1

[eluser]Unknown[/eluser]
Hi there,

Does anyone can help me to do this, i want to put query result in some column of a table,
but how to do a foreach method in add_row function of table class.
i.e ;
Code:
$result = $this->other_model->get_something();
$this->table->add_row(
             'column 1',
             'column 2',
             'i want to put a form here with a select & some option from $result looping        
               array'
          );


Thanks before for any response to this newb question ... ;-)
#2

[eluser]Unknown[/eluser]
you can pass cells to add row in an array
you could have
Code:
$result_array = array('column1','column2');
foreach($result as $item){
$result_array[]=$item->name;
}
$this->table->add_row($result_array);
so you generate the array before calling add_row.
Probably it is possible to do it inside the function, but I suppose this is cleaner anyway.




Theme © iAndrew 2016 - Forum software by © MyBB