我正在尝试获得前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();
}
答案 0 :(得分:0)
一种选择是使用在循环中递增的计数器。然后根据当前行的位置设置一个类。
arr.every(b => b)