standings.php
<?php
include("dbconnect.php");
$league = $_GET['league'];
$season = $_GET['season'];
$sql="SELECT DISTINCT RACENUMBER FROM r07leaguerace WHERE leaguenumber = '".$league."' and seasonnumber = '".$season."'";
$result = mysql_query($sql);
$racecount = mysql_num_rows($result);
$sqltotal="SELECT r07leagueracedrivers.driver, SUM(r07leagueracedrivers.points) as totalpoints FROM r07leagueracedrivers, r07leaguerace WHERE r07leagueracedrivers.leagueraceid = r07leaguerace.id and r07leaguerace.leaguenumber = '".$league."' and r07leaguerace.seasonnumber = '".$season."' group by r07leagueracedrivers.driver order by totalpoints desc";
$resulttotal = mysql_query($sqltotal);
$drivercount = mysql_num_rows($resulttotal);
if ($league == 1) $leaguename = "division 1";
else if ($league == 3) $leaguename = "division 2";
else if ($league == 4) $leaguename = "pacific league";
?>
<table width="100%" border="0" cellspacing="0" cellpadding="6" style="background-color: #FBFBFB; border: 1px solid #CCCCCC;" class="text1">
<tr>
<td>
<strong>Presto GP League season <?php echo $season." ".$leaguename; ?></strong><br />
<br />
Click on Race1, Race2 etc to see detailed results. <br /><br />
<!-- Drivers below the first line at season end will have to qualify for further participation in 1st division. Drivers below the second line will be relegated to 2nd division.<br />
-->
<table width="400" border="0" cellspacing="0" cellpadding="2" class="results">
<tr height="20">
<td height="20" colspan="2"><strong>Points</strong></td>
<td height="20" colspan="2" align="center" valign="top"> </td>
<td height="20" colspan="2" align="center" valign="top"> </td>
</tr>
<tr height="20">
<td height="20"></td>
<td><u>Driver</u></td>
<?php
for ($i=1; $i<=$racecount; $i++) {
echo "<td align='right'><u><a href='
http://prestogp.com/index.php?view=leagueraceresult&season=".$season."&league=".$league."&racenumber=".$i."'>Race".$i."</a></u></td>";
}
?>
<td align="right"><u>TOTAL</u></td>
</tr>
<?php
$placecount = 1;
while($row = mysql_fetch_array($resulttotal)) {
$sqlraces="SELECT r07leagueracedrivers.driver, r07leaguerace.racenumber, r07leagueracedrivers.points FROM r07leagueracedrivers, r07leaguerace WHERE r07leagueracedrivers.leagueraceid = r07leaguerace.id and r07leaguerace.leaguenumber = '".$league."' and r07leaguerace.seasonnumber = '".$season."' and r07leaguerace.racetype = '1' and r07leagueracedrivers.driver = '".$row['driver']."' order by r07leaguerace.racenumber asc";
$resultraces = mysql_query($sqlraces);
$row2 = mysql_fetch_array($resultraces);
echo "<tr height='20'><td height='20'>";
if ($row['totalpoints'] == $lastscore and $row['totalpoints'] != 0) echo ($placecount-1).".";
else if ($row['totalpoints'] == 0) echo "-";
else echo $placecount.".";
echo "</td>";
echo "<td height='20'>".$row['driver']."</td>";
$resultcount = 0;
for ($i=0; $i<$racecount; $i++) {
echo "<td align='right'>";
if ($row2['racenumber'] == $i+1) {
echo $row2['points'];
$row2 = mysql_fetch_array($resultraces);
// $resultcount++;
}
else {
echo "-";
// mysql_data_seek($resultraces, $resultcount-1);
}
echo "</td>";
}
echo "<td align='right'>".$row['totalpoints']."</td></tr>";
$placecount++;
$lastscore = $row['totalpoints'];
}
?>
</table>
</table>