0
我想獲得前3名的結果,並使每一行具體。 例如,我如何「簽名」或「名稱」行結果? (PHP)
該一個得票最多是一個數, 所述一個與所述第二最票數是2號, 與第三最多票數的一個是3號,
那麼我喜歡設計它們,我不知道從哪裏開始。
有沒有一種方法可以按照'按行排序',如果行高於然後第二高*,特別對待每一行?
這是我當前的代碼:
$filter = $_GET["filter"];
if ($filter == "") {
$query = "SELECT * FROM toplist WHERE Serverversion > 0 ORDER BY Votes DESC";
} else if ($filter == "custom") {
$query = "SELECT * FROM toplist WHERE Servertype = 'custom' AND Serverversion > 0 ORDER BY Votes DESC";
} else if ($filter == "pvp") {
$query = "SELECT * FROM toplist WHERE Servertype = 'pvp' AND Serverversion > 0 ORDER BY Votes DESC";
} else if ($filter == "economy") {
$query = "SELECT * FROM toplist WHERE Servertype = 'economy' AND Serverversion > 0 ORDER BY Votes DESC";
} else if ($filter == "remake") {
$query = "SELECT * FROM toplist WHERE Servertype = 'economy' AND Serverversion > 0 ORDER BY Votes DESC";
} else if ($filter == "all") {
$query = "SELECT * FROM toplist WHERE Serverversion > 0 ORDER BY Votes DESC";
}
if ($result = $con->query($query)) {
while ($toplist = $result->fetch_assoc()) {
echo '
<tr>
<td><img src="'.$toplist["Bannerlink"].'" width="468" height="60" /></td>
<td>'.ucfirst($toplist["Servername"]).'</td>
<td>'.ucfirst($toplist["Servertype"]).' (Rev. '.ucfirst($toplist["Serverversion"]).')</td>
<td>'.$toplist["Votes"].'</td>
<td><a href="'.$toplist["Serverwebsite"].'" target="blank" class="btn btn-primary">Visit Website</a></td>
<td><a href="profile.php?profile='.$toplist["ID"].'" class="btn btn-success">Visit profile</a></td>
</tr>
';
}
$result->free();
}
謝謝你隊友,它的工作! –