[eluser]rainman[/eluser]
[quote author="PhilTem" date="1340904008"][quote author="LuckyFella73" date="1340899396"]I'm sure you could sum the prices with a sql query but I'm not
that good at building such queries ..[/quote]
Code:
$this->db->select_sum('price', 'renamed_result_field');
$query = $this->db->get('table_name'');
echo $query->renamed_result_field; // Will prompt the sum of all prices in your table
Probably the fastest version (as long as you don't have such large db data) than running it within the view or a separate foreach-loop

[/quote]
Agree'd with the above. I use the model for items like that.
You could do the following as well:
Code:
$where = array('fieldname' => 'value'); // I like using this method so I can edit my query quickly.
$this->db->select_sum('price', 'renamed_result_field');
$query = $this->db->get_where('table', $where);
$results = $query->result();
return $results;