Over a million developers have joined DZone.

Running Total In PHP

·
// output running total
// userID,posts,runningTotal|
// 2,23434,28330|
// 6,3443,4896|
// 1,422,1453|
// 3,344,1031|
// 4,344,687|
// 5,343,343|


$q = mysql_query("select * from `members` order by `posts` DESC");
echo 'userID,posts,runningTotal|
'; while($a = mysql_fetch_row($q)){ echo "$a[0],$a[1],$total|
"; $total = $total - $a[1]; }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}