Hey everyone,
I am trying to use this code to pull out the goals for (GF) and goals against (GF)of a team rom the db. Right now this code takes the score to determine weather the team won, lost or tied. Any help is appriciated.
I can only get to add only two scores, but no more from the database
example of what i am doing http://annapolismariners.msnhockey.com
<?php
include("config.php");
$open = mysql_connect($hostname,$user,$password);
mysql_select_db("$db",$open);
//GET STAT INFORMATION
$wins = '0';
$losses = '0';
$gp = '0';
$otlosses = '0';
$winper = '0.00%';
$sql_standings = "SELECT * FROM schedule_scores WHERE
(team1 = '0001' OR team2 = '0001') AND (team1_score >('0')) AND
season = '000000000001'";
$res = mysql_query($sql_standings) or die (mysql_error());
while($r=mysql_fetch_array($res)){
if($r['team1'] == '0001'){
$result = $r['team1_score'] - $r['team2_score'];
if($result < 0){
if($r[ot_game] == 1) {
$otl = 1;
$lose = 0;
$win = 0;
} else {
$lose = 1;
$otl = 0;
$win = 0;
}
} else {
$win = 1;
$otl = 0;
$lose = 0;
}
}
if($r['team2'] == '0001'){
$result = $r['team2_score'] - $r['team1_score'];
if($result < 0){
if($r[ot_game] == 1) {
$otl = 1;
$lose = 0;
$win = 0;
} else {
$lose = 1;
$otl = 0;
$win = 0;
}
} else {
$win = 1;
$otl = 0;
$lose = 0;
}
}
$ga1 = $team2_score;
$ga2 = $team1_score;
$wins += $win;
$losses += $lose;
$otlosses += $otl;
$gp = ROUND($wins + $losses + $otlosses);
$winper = ROUND($wins / $gp);
}
$points = ($wins * 2) + $otlosses;
echo "<tr>
<td
<tr>
<td colspan='2'>
<table border='0' width='100%' cellspacing='0' cellpadding='4'>
<tr>
<td colspan='2' width='100%'>
<table class='teams' border='0' width='100%' cellspacing='1' cellpadding='2' style='border: 1px solid #0E2046'>
<tr>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>GP</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>W</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>L</font></th><th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>OTL</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>P</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>Win%</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>PK%</font></th>
<th nowrap bgcolor='#0E2046' width='11%'><font color='#FFFFFF'>PP%</font></th>
</tr>
<tr>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$gp</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$wins</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$losses</td><td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$otlosses</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$points</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>$winper</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>0%</td>
<td align='center' nowrap bgcolor='#F7F7F7' width='11%'>0.00%</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width='50%'>
<table class='teams' border='0' width='100%' cellspacing='1' cellpadding='2' style='border: 1px solid #0E2046'>
<tr>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>GF</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>GFPG</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>GA</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>GAPG</font></th>
</tr>
<tr>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>
$teamgf</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>$teamga01</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
</tr>
</table>
</td>
<td width='50%'>
<table class='teams' border='0' cellspacing='1' cellpadding='2' width='100%' style='border: 1px solid #0E2046'>
<tr>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>PPG</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>PPGA</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>SHGF</font></th>
<th nowrap bgcolor='#0E2046' width='25%'><font color='#FFFFFF'>SHGA</font></th>
</tr>
<tr>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
<td nowrap align='center' bgcolor='#F7F7F7' width='25%'>0</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan='2'>
<table border='0' width='100%' cellspacing='0' cellpadding='4'>
<tr>
<td width='50%'>
<table class='teams' border='0' width='100%' cellspacing='1' cellpadding='2' style='border: 1px solid #0E2046'>
<tr>
<th bgcolor='#0E2046' nowrap>
<span style='font-variant: small-caps; text-transform: capitalize'>
<font color='#FFFFFF'>last 10 games</font></span></th>
</tr>
<tr>
<td bgcolor='#F7F7F7' align='center'><b><font size='3'>0-0-0</font></b></td>
</tr>
</table>
</td>
<td width='50%'>
<table class='teams' border='0' width='100%' cellspacing='1' cellpadding='2' style='border: 1px solid #0E2046'>
<tr>
<th bgcolor='#0E2046' nowrap>
<span style='text-transform: capitalize; font-variant: small-caps'>
<font color='#FFFFFF'>current streak</font></span></th>
</tr>
<tr>
<td bgcolor='#F7F7F7' align='center'><b><font size='3'>No Games Played
</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
";
?>
thanks for our time