Jump to content

php mysql help


Adam79
Go to solution Solved by Barand,

Recommended Posts

I am looking for some help, our hockey team has 20 years of stats that i need to sort.

I need to figure out most goals, assists and points by a player in all the years that the player has played.

i was wondering what the easiest way to go about this would be?


Currently i have a database field for (id, name, gp, goals, assists, pim, year)


my problem is i am inputting all the info individually by year so a player could play 5 years and some could play 1 but i want to show the combined totals for each player 

example player1 played 5 years i have all his stats in the database i want to combine all the stats from the 5 years that players played and show it on a single page like total amount of goals, assists pts, gp(games played) pim like so
 

Name  - Player1

 

GamesPlayed - 123,

 

Goals - 93,

 

Assists - 91

 

Pts - 184,

 

Pim - 239

any help is greatly appreciated

thanks

Link to comment
Share on other sites

Assuming that the field 'games played' represents that number of games that player with name 'name' played in the given year, set in the 'year' field, then you could do a simple SELECT COUNT() for each field that you need tallies for. This would obviously mean that for each player that's played more than one year, they'll have their name in the database more than one time. Usually the best idea would be to have the name in there only once, by normalizing your databases (I think it's called), to separate data out into related tables..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.