Hello,
I have posted here before. Please look at the code below and see if you can spot any errors.
<?php
$username="XXXX";
$password="XXXX";
$database="XXXX";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT CONCAT(p.FirstName, ' ', p.LastName) AS 'PlayerName', count(*) as 'Games', round(s.minutes/'Games',1) as 'MPG', sum(s.fgm) as 'tfg', sum(s.fga) as 'tfga', round('tfg'/'tfga',3) AS 'FG%',sum(s.thgm) as 'tthg', sum(s.thga) as 'tthga', round('tthg'/'tthga',3) AS thg%', sum(s.ftm) as 'tft', sum(s.fta) as 'tfta', round('tft/'tfta',3) AS 'FT%', sum(s.orb) as 'torb', sum(s.drb) as 'tdrb', round(('torb'+'tdrb')/'Games',1) as 'RPG', sum(s.ast) as 'tast', round('tast'/'Games',1) as 'APG', sum(s.stl) as 'tstl', round('tstl'/'Games',1) as 'SPG', sum(s.blk) as 'tblk', round('tblk'/'Games',1) as 'BPG', sum(s.tpoints) as 'PTS', round('PTS'/'Games',1) as 'PPG' FROM Players p, stats s WHERE s.player_id = p.player_id group by p.player_id";
$result2=mysql_query($query);
$num2=mysql_numrows($result2);
mysql_close();
?>
I am trying to display player totals and averages. I only have 2 players and 2 games of stats so far until i can figure this out. The closest I have been able to come has actually listed both players, but the first players totals and percentages are based on his AND the other player's numbers, while the second player lists correctly. =(
I am assuming that this mysql select statement is the cause, but I am not finding the problem. I have gotten some wonderful help from this forum before so I figured to try this problem here too =)
Thanks for any advice!