Jump to content

Standings help


keefedog

Recommended Posts

Hi,
Relatively new to php / mysql and need some help with generating standings from a football schedule. I have a 'schedules' table in a mysql database with 'vteam', 'vscore', 'hteam', 'hscore' among the columns.

I have it so users login and input scores which get posted to my website but would also like this process to update standings as well.

I've pieced together some code to generate the standings page. I've managed to generate each team's away W-L records so far but the problem is trying to do the same for home records and keeping the info on the same line of the html table as the relevant team. I've been playing with the UNION idea for some time now and can't get it working right. Any help would be awesome. Thanks in advance.

Below is the relevant code which is working for the away records:

php:
--------------------------------------------------------------------------------
echo "<table align=center width=530 cellpadding=1 cellspacing=0 border=0>";
echo "<tr><td colspan=9><b>2005 Standings</b></td></tr>";
echo "<tr><td>Team</td><td>GP</td><td>W</td><td>L</td><td>Home</td><td>Road</td><td>F</td><td>A</td><td>Pts</td></tr>";

$sqlquery = '(SELECT vteam AS team,SUM(IF(vscore > hscore, 1, 0)) AS vwins,
SUM(IF(hscore > vscore, 1, 0)) AS vlosses FROM schedules GROUP BY team)';

$result = mysql_query($sqlquery);
while($row = mysql_fetch_array($result)) {

echo "<tr><td>$row[team]</td><td></td><td></td><td></td><td></td><td>$row[vwins]-$row[vlosses]</td><td></td><td></td><td></td></td>";
}

mysql_free_result($result);
echo "</table>";
?>

--------------------------------------------------------------------------------
Link to comment
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.