I need to sum rows and columns like in a spreadsheet
- Single Page
Posted 08 November 2011 - 11:39 AM
This is GREAT stuff!! I had almost given up on codeigniter when I found your script!
I am using version 1.1.3.
I need to sum rows and columns.
Can you tell me how to do that?
[u]__[b]_Item_[/b]____[b]J[/b]___[b]F[/b]___[b]M[/b]_ [b]Tot [/b][/u]
[u][b]Good Days[/b] | 10 | 20 | 30 | 60 |[/u]
[u][b] Bad Days[/b] | 20 | 30 | 40 | 90 |[/u]
[u][b]Total Days[/b] | 30 | 50 | 70 | 150 |[/u]
Any help you could give would be great!!
Thank you again for your GREAT work!!!!!!!
Rich Halsey
www.marricorp.com
Posted 10 November 2011 - 00:22 AM
Thanks in advance!!
Posted 11 November 2011 - 02:06 AM
Assume that you have 2 rows in your table_day(Item, J, F, M).
To make total row, you might need to make such a view (let's assume it as view_a) :
SELECT item, J, F, M, (J+F+M) as total FROM table_day
For total column, it might be more complicated.
You should make another view (let's assume it as view_b ):
SELECT 'total', sum(J) as J, sum(F) as F, sum(total) as total FROM view_a;
And you should make the third view that combine view_a and view_b (I forgot the detail, but you might googling for that).
I hope it can help.
Ah, there is some side effect of this, you should not edit, add, or delete from a view, that's mean that the grid can only be viewed (or you will need some complicated callback).
goFrendiAsgard
Posted 11 November 2011 - 10:23 AM