Jump to content


Standings help

  • Please log in to reply
1 reply to this topic

#1 keefedog

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 25 April 2006 - 05:02 PM

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:

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>";

echo "</table>";


#2 Mortier

  • Members
  • PipPip
  • Member
  • 27 posts

Posted 29 April 2006 - 09:40 AM

Sorry but I don't quite understand what you want to do

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users