Forums
This topic is locked
PHP Calculations - New to handcoding
Posted 22 years ago
1
has voted
22 years ago 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 22 years ago
22 years ago 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 ( illuminatus@mail.com )
i hope this helps.
--J
P.S. i killed kenny
Edited by - poolio on 20 Jun 2002 14:55:25
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 ( illuminatus@mail.com )
i hope this helps.
--J
P.S. i killed kenny
Edited by - poolio on 20 Jun 2002 14:55:25