Collating Values from database fields
| From: | Matt MacLeod | Date: | Fri, 14 Mar 2003 10:35:18 +0000 |
| Subject: | Collating Values from database fields | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-139695@lists.php.net to get a copy of this message | ||
Hi,
I'm building a site for my rugby club and I want to present players'
data ie: number of appearances, points scored and so on.
I have three tables in my database: a table of tournaments (date,
location, opposition, etc), a table of players (name, contact details,
position, etc) and a table of appearances (fixtureID, playerID, tries
scored, penalties scored, cautions etc.
When a player is selected from a drop-down list, their data will appear
in a table by drawing from the 'appearances' table based on the player's
ID thus:
Player: Matt MacLeod
---------------------
Tournament 1 / 19/01/2003 / 2 tries / 0 pens / 0 cautions
Tournament 2 / 24/03/2003 / 4 tries / 3 pens / 1 caution
Tournament 3 / 27/03/2003 / 0 tries / 3 pens / 0 cautions
I then want to print the player's totals thus:
3 tournaments / 6 tries / 6 pens / 1 caution
This is where I get stuck. I know how to display the data on a
tournament by tournament bais, and get PHP to build an additional table
row for each appearance by the player, but I am unsure of how to add up
the columns and print the totals at the end of the table.
Any help would be greatly appreciated.
Thanks,
Matt