Re: Collating Values from database fields

From: Date: Fri, 14 Mar 2003 13:34:41 +0000
Subject: Re: Collating Values from database fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-139709@lists.php.net to get a copy of this message
Matt, You are looking at least 2 separate select queries - one to retrieve the player data on a tournament by tournament basis and a second query to 'calculate' the summary data. Now, you will be needing the GROUP BY clause in the second query while drawing on at least the player and appearances tables (check out GROUP BY in the MySQL (I assume you are using MySQL) online manual.) Then simply print out the results of the respective select queries. David Eisenhart "Matt Macleod" <matt@bigbarn.co.uk> wrote in message news:000601c2ea15$6d0e9440$0501a8c0@Matt... > 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 >

« previous php.general (#139709) next »