I know this has been asked before and I have done the research but just cant seem to get it right.
Basically I am trying to extract the raceName from the Array but when I add the the line of code it removes the first line from the while query result.
I know its related to the two mysqli_fetch_array statements but I am looking for some direction.
<?php
$id = $_GET['id'];
if($id == "") {
echo "Race is unavailable";
echo "<br>";
} else {
$result = mysqli_query($mysqli, "SELECT RaceEvent.raceName, horse.horseName, RaceData.raceCode, RaceData.tabNumber, RaceData.barrier, horse.horseCode, Jockey.jockeyName
FROM ((((RaceMeet
INNER JOIN RaceEvent
ON RaceEvent.meetCode=RaceMeet.meetCode)
INNER JOIN RaceData
ON RaceEvent.raceCode=RaceData.raceCode)
INNER JOIN horse
ON horse.horseCode=RaceData.horseCode)
INNER JOIN jockey
ON jockey.jockeyCode=RaceData.jockeyCode)
WHERE RaceEvent.raceCode = '$id'");
$row = mysqli_fetch_array($result);
printf ("<h3>%s \n </h3>", $row['raceName']);
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['horseCode'] . "</td>";
echo "<td>" . $row['horseName'] . "</td>";
echo "<td>" . $row['jockeyName'] . "</td>";
echo "<td>" . $row['tabNumber'] . "</td>";
echo "<td>" . $row['barrier'] . "</td>";
}
}
?>
This line is meant to be the race name and is only meant to be returned once:
$row = mysqli_fetch_array($result);
printf ("<h3>%s \n </h3>", $row['raceName']);
Whilst the while loop is meant to return the number of rows, pending the number of horses in the race:
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['horseCode'] . "</td>";
echo "<td>" . $row['horseName'] . "</td>";
echo "<td>" . $row['jockeyName'] . "</td>";
echo "<td>" . $row['tabNumber'] . "</td>";
echo "<td>" . $row['barrier'] . "</td>";
}
I appreciate your time an help