Welcome Guest, Not a member yet? Register   Sign In
Formatting columns in a table
#1

[eluser]skypanther[/eluser]
I'm pulling data from a database then outputting it in an HTML table. That part's fine. But what I can't figure out is how to apply formatting to the individual columns in the results.

So, the first column is a part number, then a product name, then a price, etc. I want to format the price column as money (applying the money_format() or similar function).

My controller:
Code:
// call my model's function to grab the data:
$data['results'] = $this->productsmodel->get_products();
// load the HTML Table Class
$this->load->library('table');
$this->table->clear();
$this->table->set_heading('Part #', 'Name', 'List price', 'Parts', 'Hours', 'Total');
$this->template->set('title','Products');
$this->template->load('template','products', $data);

And my view:
Code:
echo $this->table->generate($results);

Works fine but how can I format columns? I tried manually adding rows with $this->table->add_row() but I can't figure out how to extract the data returned by my model. BTW, it's just calling $query = $this->db->get('parts'); I could do the formatting with jQuery but there are a lot of rows and that would be slow I'm guessing.

Thanks,
Tim


Messages In This Thread
Formatting columns in a table - by El Forum - 03-09-2011, 03:40 PM
Formatting columns in a table - by El Forum - 03-09-2011, 08:35 PM
Formatting columns in a table - by El Forum - 03-09-2011, 08:46 PM
Formatting columns in a table - by El Forum - 03-09-2011, 10:50 PM
Formatting columns in a table - by El Forum - 03-10-2011, 06:54 AM
Formatting columns in a table - by El Forum - 03-10-2011, 07:44 AM
Formatting columns in a table - by El Forum - 03-10-2011, 07:58 AM
Formatting columns in a table - by El Forum - 03-10-2011, 08:45 AM
Formatting columns in a table - by El Forum - 03-10-2011, 09:57 AM
Formatting columns in a table - by El Forum - 06-07-2011, 02:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB