Adding Columns in PHP
I am trying to add columns together to get a total at the end of each
column, I searched this topic and tried to do what it said but got the an
error "You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'SELECT SUM(Sea) FROM PlayerStats; FROM SeasonStats WHERE
SeasonStats.PlayerID=' at line 2" I am pretty new at this and cannot seem
to figure out how to make it work. Any help would be greatly appreciated.
$oPlayerStats = mysql_query("
SELECT SeasonStats.Sea, SeasonStats.Team, SeasonStats.GP,
SeasonStats.Goals, SeasonStats.Assists, SeasonStats.Points,
SeasonStats.PlusMinus, SeasonStats.Pim, SeasonStats.PP, SeasonStats.SH,
SeasonStats.GW, SeasonStats.GT, SeasonStats.S
SELECT SUM(Sea) FROM PlayerStats;
FROM SeasonStats
WHERE SeasonStats.PlayerID=$iPlayerID
ORDER BY SeasonStats.Sea;
") or die(mysql_error());
echo "<br><br><table border=1 cellpadding=1>";
echo "<tr>";
echo "<td>Season</td> ";
echo "<td>Team</td> ";
echo "<td>GP</td> ";
echo "<td>G</td> ";
echo "<td>A</td> ";
echo "<td>P</td> ";
echo "<td>PIM</td> ";
echo "<td>+/-</td> ";
echo "<td>PPG</td> ";
echo "<td>SHG</td> ";
echo "<td>GWG</td> ";
echo "<td>GTG</td> ";
echo "<td>Shots</td> ";
while($row = mysql_fetch_array($oPlayerStats))
{
echo "<tr>";
echo "<td>".$row['Sea']."</td> ";
echo "<td>".$row['Team']."</td> ";
echo "<td>".$row['GP']."</td> ";
echo "<td>".$row['Goals']."</td> ";
echo "<td>".$row['Assists']."</td> ";
echo "<td>".$row['Points']."</td> ";
echo "<td>".$row['Pim']."</td> ";
echo "<td>".$row['PlusMinus']."</td> ";
echo "<td>".$row['PP']."</td> ";
echo "<td>".$row['SH']."</td> ";
echo "<td>".$row['GW']."</td> ";
echo "<td>".$row['GT']."</td> ";
echo "<td>".$row['S']."</td> ";
$result = mysql_query('SELECT SUM(Sea) AS value_sum FROM codes');
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];
No comments:
Post a Comment