keefedog Posted April 25, 2006 Share Posted April 25, 2006 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>";?>-------------------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
Mortier Posted April 29, 2006 Share Posted April 29, 2006 Sorry but I don't quite understand what you want to do Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.