Reputation: 205
I am new to codeigniter. I used the class HTML Table to display results.
I have two columns. First column is Description and Second column is Amount. I want to display the amount in right align as it is in currency.
Is there any possible way to do it?
Upvotes: 1
Views: 1786
Reputation: 885
$this->load->library('table');
$this->table->set_heading(array('Description', array('data' => 'Amount', 'align' => 'right')));
$this->table->add_row('Description 1', array('data' => '$1.99', 'align' => 'right'));
echo $this->table->generate();
Any key you add to the array other than data will become an attribute on the td or th
Upvotes: 1
Reputation: 5166
Set your table template read this http://ellislab.com/codeigniter/user-guide/libraries/table.html
$tmpl = array (
'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
'heading_row_start' => '<tr>',
'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
'row_start' => '<tr>',
'row_end' => '</tr>',
'cell_start' => '<td>',
'cell_end' => '</td>',
'row_alt_start' => '<tr>',
'row_alt_end' => '</tr>',
'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>',
'table_close' => '</table>'
);
$this->table->set_template($tmpl);
Upvotes: 0