更新,以提供更好的解釋最高級別的PHP MYSQL(在RuneScape宗族榜):順序按
我在試圖創造一個高分功能爲我的家族在一個遊戲叫在RuneScape不過我還是要說的過程很「知道了如何通過‘總水平’
Working Demo without sorting by total level
例如silenthawk排行榜的排序應該是頂部,因爲他一共有1941。我與列ID,等級和playername
我正在做一個SQL查詢來獲取所有的氏族的人,然後通過使用一種叫做oldschoolhiscore頁面下車在RuneScape網站高分的表稱爲rsusers .php,我發現在github上(linked here) - 我想我所要做的就是編輯這個頁面,按照'總計'排序,但我不確定?
這裏是非常精簡和簡單的演示和代碼:
代碼:
<?php
require 'OldSchoolHiscore.php';
$dbhost = 'localhost';
$dbuser = 'xxxx';
$dbpass = 'xxxxxxxxx';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'xxxxxx';
$connection = mysql_select_db($dbname);
$sql = "SELECT * FROM rsusers";
$rs_result = mysql_query ($sql);
?>
<table class="table table-striped table-list-search">
<thead>
<tr>
<td>Name</td>
<td>Level</td>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
$hs = new OldSchoolHiscore($row['username']);
$total_level = $hs->getSkillLevel('overall');
echo "<tr>";
echo "<td>".$row['username']."</td>";
echo "<td>$total_level</td>";
echo "</tr>";
}
?>
</tbody>
</table>
SQL
INSERT INTO rsusers
(username, clanrank)
VALUES
('Dwh_Hunters', 'lieutenant'),
('SilentHawk', 'general'),
('Sir Novel', 'lieutenant'),
('Ryuk Yagami', 'general');
見https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to -be-a-very-simple-sql-query – Strawberry