Hello everyone. I really appreciate any help you can offer. I am a a bit new to the idea of arrays in PHP. Thanks in advance.
I am trying to do a couple things here. I am trying to work on a hall of fame for a fantasy football league I've designed. I have a table that looks like this:
ID Player1ID Player2ID Player1Score Player2Score Week
1 Brady Manning 35 24 9
2 Williams McGahee 14 22 9
3 Brady Losman 25 18 10
4 Jones Peterson 20 33 10
5 Rivers Brady 34 19 11
I am trying to add up all the points for each player for the entire season. For example, Brady ..35+18+19...Ive tried doing a Union query to combine the Player1ID and Score with the Player2ID and Score, but it's not working.
Something like:
SELECT Player1ID AS Player, SUM(Player1Score) AS Score FROM tblScore WHERE QB = Brady UNION SELECT ALL Player2ID AS Player, SUM(Player2Score) AS Score FROM tblScore WHERE QB = Brady SORT BY Points DESC
That doesnt seem to work. It doesnt like the combination of SUM and UNION I think...So I figured if I can put it all in an Array with the 1 value storing the PlayerName (or ID) and the other one storing all their values(scores from each week). This way I can just add up all the values in the Array associated with that PlayerID. After I can then sort them by TotalPoints...I am having trouble figuring this all out.
Could someone please point me in the right direction? Or if you see a way of working the SQL, that would be even better I suppose! Thanks again.