Forum Moderators: open
$query = "SELECT SUM(comptipsterselections.profit), comptipsterselections.stable
FROM comptipsterselections INNER JOIN comptipsterboard
ON comptipsterselections.stable=comptipsterboard.stable
WHERE comptipsterboard.comp = 'aintree 2010'
GROUP BY comptipsterselections.stable ORDER BY SUM(comptipsterselections.profit) DESC";
$result = mysql_query($query) or die(mysql_error());
// Set-up table
echo "<table class='correctenglish' border='1' cellpadding='4' cellspacing='0' width='75%'>";
echo "<tr class='toprow'> <th>Stable</th> <th>Daily Profit</th></tr>";
// Print out result
while($row = mysql_fetch_array($result)){
$link='/site/competitions/tipster'.$row['link'];
echo "<tr><td>";
echo "<a href='$link'>";
echo $row['stable'];
echo "</td><td>";
echo " £". $row['SUM(comptipsterselections.profit)'];
echo "</td></tr>";
}
echo "</table>";
?>