Help with a math function total
Posted: Mon Mar 29, 2004 10:00 pm
Ok guys I'm trying to incorporate a table with some totals of baseball stats of all the players on a particular team. I have some nice player breakdowns, but need to figure out a way to just total a query and select a partical team then be able to display a little table with their totals. If this is what i use for the team, how would a put the particual math work for each cateogry?? I'm good with make work in submit forms but suck outside of it. Just some basic adding would work for now, if i can figure out just one total i can then figure out the math work for other complex categories such as avg.
Here is what I have:
<?
$query = mysql_query("select * from pit where team = 'Ana'");
?>
<?
$color = "#CCCCCC";
while ($row = mysql_fetch_array($query))
{
echo "<tr bgcolor=\"$color\"><td><b><img src=$row[logo]height=28 width=33</td><td><font size=2><div align=center><b><a href=pitplayer.php?pit_id=$row[pit_id]>$row[pitname]<b>$row[w]</b></td><td><font size=2><div align=center><b>$row[l]</b></td><td><font size=2><div align=center><b>$row[s]</b></td><td><font size=2><div align=center><b>$row[k]</b></td><td><font size=2><div align=center><b>$row[IP]</b></td><td><font size=2><div align=center><b>$row[ER]</b></td><td><font size=2><div align=center><b>$row[era]</b></td></tr>";
?>
------------------------
Th above code is what I use just for the filetring in the players. But i figure if i can learn to add the totals code and math work to it. I just don;t know how to go about it.
Would I put the math work in the Echo?? Or before it? And how would i change the query around if needed? I'm thinking I just need to add the math work probably to the echo???
Thanks in Advance
Here is what I have:
<?
$query = mysql_query("select * from pit where team = 'Ana'");
?>
<?
$color = "#CCCCCC";
while ($row = mysql_fetch_array($query))
{
echo "<tr bgcolor=\"$color\"><td><b><img src=$row[logo]height=28 width=33</td><td><font size=2><div align=center><b><a href=pitplayer.php?pit_id=$row[pit_id]>$row[pitname]<b>$row[w]</b></td><td><font size=2><div align=center><b>$row[l]</b></td><td><font size=2><div align=center><b>$row[s]</b></td><td><font size=2><div align=center><b>$row[k]</b></td><td><font size=2><div align=center><b>$row[IP]</b></td><td><font size=2><div align=center><b>$row[ER]</b></td><td><font size=2><div align=center><b>$row[era]</b></td></tr>";
?>
------------------------
Th above code is what I use just for the filetring in the players. But i figure if i can learn to add the totals code and math work to it. I just don;t know how to go about it.
Would I put the math work in the Echo?? Or before it? And how would i change the query around if needed? I'm thinking I just need to add the math work probably to the echo???
Thanks in Advance