Adding together all entries of a database field

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 2, 2009   (RSS)

By dwellingproductions - March 31, 2009

Hello! Hopefully there's a fairly straight-forward way to do this.

I have a multi-record where each record contains member information. One of these items is a "point" value made up of only numbers. (The administrator assigns points to each member based on merit.) I am currently displaying each individual member's point value on their member page.

What my client now wants is for all the points of every member to be added together (to show an organizational, or group, total) and then have that result (total) also displayed on each member's individual page.

How would I go about doing this? Thanks, in advance, for any assistance!

Jeremy
---------------------------

Dwelling Productions

www.dwellingproductions.com

Re: [dwelling] Adding together all entries of a database field

By ross - April 1, 2009

Hi Jeremy

Thanks for posting!

What I would do is create a separate page called totalScore.php or something like that and set it up like a list viewer page for this section.

All you'll need it to do is output the score from each member. You don't need any HTML. Just the view code, the foreach loop and the score field.

Right out side the foreach loop, create a variable called $totalScore. Then inside the foreach loop, increment that variable with the value from your score field.

$totalScore += $record['score']

After the forloop ends, put this: echo $totalScore

You should then be able to include this file on your members pages.

Does that make sense? Give it a shot and let me know if I can elaborate on any of this.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/