views:

186

answers:

2

I simply need to sum the value of about 15 columns (say, 20-35) in codeigniter.

What's the best way to do this?

+3  A: 

Do it exactly the same way you would in plain SQL. If MySQL then you can do this:

$this->db->select('SUM(field1) + SUM(field2) + SUM(field3) as total', FALSE);

The FALSE stops auto-escaping.

Phil Sturgeon
A: 

I am looking for same answer where i need a loop till specific node position() and sum of till.

i.e.

if my position is 2 then sum of node[1] + node [2] and if my position is increased to 5 then node[1] + node [2] + node[3] + node [4] + node[5]

what will be xsl

thanks in advanced Kedar Vijay Kulkarni

Kedar
Kedar; welcome to stackoverflow! If you have a question you should ask it in a separate thread by using the `Ask A Question` button in the upper right-hand corner.
Sean Vieira