[eluser]fivestringsurf[/eluser]
First off, this is my first post here as i just found code igniter and have been learning it all week. I was dead-against frameworks until I tried this one. It's fantastic. I was sold once i read the clear documentation with simple code examples
Anyway... I'm pulling data from a db and would like to display it in tables. The code igniter table class does so much stuff with so few lines of code ( i always hated working with tables in php)
but here's the catch. I need to place some unique table information with each <tr> tag.
when using the set_template method it seems to set all the <tr>'s to the last template used. The templating is not honored each step of the row creation only according to last row templating set.
some code:
Code:
// get database results
$db_results = $this->crud_books->read($dewey_num);
//style table
$dataArr = array('Title', 'Author', 'Year Published', 'Edition', 'Glossary');
$this->table->set_heading($dataArr);
//bulld table
foreach($db_results->result() as $row){
//write unique books_id to onclick
$tmpl = array( 'row_start' => '<tr on click="dialog('.$row->books_id.');">');
$this->table->set_template($tmpl);
$dataArr = array($row->title, $row->author, $row->year_published, $row->edition, $row->glossary);
$this->table->add_row($dataArr);
}
$data['bookData'] .= $this->table->generate();
$this->table->clear();
essentially i am using an onclick call inside of the <tr> of each row and need those onclick values i am passing to be the id's associated with the data written in each row.
Any advice on how to achieve this?