I am trying to run a query which will provide a user on the website with:
- The competition name
- The image title
- The result (1st place, 2nd place or 3rd)
So far I have managed to pull out the below result:
<div class="grid-2">
<h3>Competition Entries</h3>
<form action = "" method = "POST">
<select name="competitionID">
<option value="">Select Competition</option>
<option value="1">Winter Warmer</option>
<option value="2">Fresh New Year</option>
<option value="3">Month of Love</option>
<option value="4">Seaside Scenery</option>
</select>
</fieldset>
</form>
<?php
$query = "SELECT `fldCompName`, `fldName`, `fldResult` FROM `tblMembEntComp` JOIN `tblCompetition` ON `tblMembEntComp`.`fldCompID`=`tblCompetition`.`fldCompID` JOIN `tblImage` ON `tblMembEntComp`.`fldMemberID`=`tblImage`.`fldMemberID` ORDER BY `fldResult` DESC LIMIT 3";
$result = $conn -> query($query);
while($row = $result -> fetch_assoc())
{
echo $row['fldCompName']." ".$row['fldName']." ".$row['fldResult']."<br>";
}
?>
<button>View Competition Winners</button>
</div>
However, the results are all showing up as 17 for all of those top three entries when in the tbmMembEntComp
fldResult
I have 19, 17 and 11. Can someone just highlight where I've gone wrong and give guidance on what the query should be.