Running total
Posted: Wed Mar 26, 2008 4:40 pm
I am returning 'pages' of data from a ms sql database. The sql server handles the paging, and I now need to add a 'balance' (running total) to the data displayed.
Let's assume my data is as follows:
Amount Balance
20,000 20,000
30,000 50,000
-5.02 49,994.98
93.27 50,088.25
8,512.47 58,600.72
If I return two records per page, page two will show
Amount Balance
-5.02 49,994.98
93.27 50,088.25
Does anyone here have an idea of how cto handle the running total in PHP?
I can create a running total from the first page (0 + 20,000 + 30,000 etc) and pass the total to the next page for it to add it's contents to. But handling the running total when stepping backward through the pages has me stumped right now.
Let's assume my data is as follows:
Amount Balance
20,000 20,000
30,000 50,000
-5.02 49,994.98
93.27 50,088.25
8,512.47 58,600.72
If I return two records per page, page two will show
Amount Balance
-5.02 49,994.98
93.27 50,088.25
Does anyone here have an idea of how cto handle the running total in PHP?
I can create a running total from the first page (0 + 20,000 + 30,000 etc) and pass the total to the next page for it to add it's contents to. But handling the running total when stepping backward through the pages has me stumped right now.