我正在尝试运行一个查询,该查询将为网站上的用户提供:
到目前为止,我已经设法得出以下结果:
<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>
但是,当我在tbmMembEntComp
fldResult
中有19、17和11时,所有前三项的结果都显示为17。错误,并提供有关查询内容的指导。
答案 0 :(得分:2)
您并没有将结果限制为一个特定的竞赛,因此它为 all 提供了成员表和竞赛表之间的联接行。
这样的事情(仅示例)
var c = new Contact(name, email);
d[c.Name] = c;
d[c.Email] = c;