Forums

PHP

This topic is locked

PHP Calculations - New to handcoding

Posted 20 Jun 2002 12:55:09
1
has voted
20 Jun 2002 12:55:09 Pat Heuber posted:
i have a mysql table containing 4 teams with several workers belonging to a specific team. Each member of the team can score points that are manually stored in a score field. I managed to list the teams in order and the team members by score.

But I have to add a total score for each team resulting of the individual points of each team member. This score should be shown at the end of the table of each teamlisting.

can somebody give me a small hint how to do that ?

Replies

Replied 20 Jun 2002 14:52:39
20 Jun 2002 14:52:39 Julio Taylor replied:
The best way (i think) to handle calculations is to actually use SQL syntax to create calculations in your recordset. So, for example, you can have syntax such as:

SELECT SUM(team_scores) FROM team_table WHERE team_id = 1 GROUP BY team_id

This will give you the SUM of all the scores for the team members, and separate it by teams. It is important that you define the GROUP BY clause in your SQL to make sure the results are correctly structured.

Let me know if you need more help with this, contact me on MSN if you need to ( )

i hope this helps.

--J

P.S. i killed kenny

Edited by - poolio on 20 Jun 2002 14:55:25

Reply to this topic