Jump to content

Recommended Posts

Ok, I am running a baseball site and we have our player stats all in a table within a database. What I have is something like this, http://www.stlbleague.com/tm.php?tid=7... Now what I would like to do is have a row at the end of the pitching and hitting stats that says "Team Totals", here is a sample code that I have pulling the pitching stats:

 

$id = $_GET['tid']; // get var from URL


/* Get data. */
$sql = "SELECT player, pos, era, w, l, sv, hold, ip, bb, k, cg, sho, whip, k9 FROM 2012pitching LEFT JOIN roster ON 2012pitching.id=roster.id WHERE tid='$id'";
$result = mysql_query($sql);


?>

<table width="962" border="0" cellpadding="2" cellspacing="1" class="stats2">
<tr class='theader'>
<td align='center'>PLAYER</td>
<td align='center'>POS</td>
<td align='center'>ERA</td>
<td align='center'>W</td>
<td align='center'>L</td>
<td align='center'>SV</td>
<td align='center'>HOLD</td>
<td align='center'>IP</td>
<td align='center'>BB</td>
<td align='center'>K</td>
<td align='center'>CG</td>
<td align='center'>SHO</td>
<td align='center'>WHIP</td>
<td align='center'>K/9</td>
</tr>

<?php
$alternate = "2";
while ($row = mysql_fetch_array($result)) {
$field1 = $row["player"];
$field2 = $row["pos"];
$field3 = $row["era"];
$field4 = $row["w"];
$field5 = $row["l"];
$field6 = $row["sv"];
$field7 = $row["hold"];
$field8 = $row["ip"];
$field9 = $row["bb"];
$field10 = $row["k"];
$field11 = $row["cg"];
$field12 = $row["sho"];
$field13 = $row["whip"];
$field14 = $row["k9"];
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
}
else {
$color = "#E4E4E4";
$alternate = "1";
}
echo "<tr bgcolor=$color><td>$field1</td><td align='center'>$field2</td><td align='center'>$field3</td><td align='center'>$field4</td><td align='center'>$field5</td><td align='center'>$field6</td><td align='center'>$field7</td><td align='center'>$field8</td><td align='center'>$field9</td><td align='center'>$field10</td><td align='center'>$field11</td><td align='center'>$field12</td><td align='center'>$field13</td><td align='center'>$field14</td></tr>";
}
echo "</table>";
?>

 

So how could I use the Team ID associated with every player that it is pulling from to add a totals row?

 

Thanks again in advance,

 

Bobby

Link to comment
https://forums.phpfreaks.com/topic/259423-table-totals/
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.