Saturday, 24 August 2013

List results of a competition by meet name

List results of a competition by meet name

I am attempting to list the results of a horse racing meet based on the
meet's name. I would like it to look like this:



RACE MEET (DATE)
RACE NAME 1. Horse (sire) owned by Farm 2. Horse (sire) owned by Farm 3.
Horse (sire) owned by Farm
RACE NAME 1. Horse (sire) owned by Farm 2. Horse (sire) owned by Farm



I have gotten it to sort of work, but it only lists the horse in 1st place
and goes onto the next race. I can't figure out how to list every placing
for that race.
Current Code:
<?php
$sql = "SELECT DISTINCT * FROM racing WHERE `meet` = '$meet' LIMIT 1";
$query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql );
while($row = mysql_fetch_array($query)){
$date= $row['date'];
echo "<h2><strong>$meet Results</strong> ($date)</h2>";
}
?>
</h2>
<?php
$sql = "SELECT *
FROM `racing`
WHERE `meet` = '$meet'
GROUP BY `race`
ORDER BY `place` "; $query = mysql_query($sql) or die( mysql_error() .
"<br />" . $sql );
while($row = mysql_fetch_array($query)){
$race= $row['race'];
$place= $row['place'];
$horse= $row['horse'];
$sire= $row['sire'];
$farm= $row['farm'];
echo "
<b>$race</b><br>
$place <a href='horse.php?horse={$row['horse']}'>$horse</a> (<a
href='sire.php?sire={$row['sire']}'>$sire</a>) owned by <a
href='owners.php?farm={$row['farm']}'>$farm</a><br>
"; }
?>

No comments:

Post a Comment