[eluser]InsiteFX[/eluser]
Here is how it is done using a Table Template:
Code:
class MY_Controller extends CI_Controller {
/**
* -----------------------------------------------------------------------
* Class variables - public, private, protected and static.
* -----------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
/**
* __construct
*
* Class Constructor PHP 5+
*
* @author Raymond King Sr.
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
$this->load->library('table');
$tmpl = array (
'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
'thead_open' => '<thead>',
'thead_close' => '</thead>',
'heading_row_start' => '<tr>',
'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
'tbody_open' => '<tbody>',
'tbody_close' => '</tbody>',
'row_start' => '<tr>',
'row_end' => '</tr>',
'cell_start' => '<td>',
'cell_end' => '</td>',
'row_alt_start' => '<tr class="alt">',
'row_alt_end' => '</tr>',
'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>',
'table_close' => '</table>'
);
$this->table->set_template($tmpl);
}
}
Now you can use add_row etc and build your table using a foreach loop on your query from the database.
In your view were you want the table generated just add this:
Code:
<?php echo $this->table->generate(); ?>