title: Order By Highest Level MYSQL PHP (Runescape Clan Highscores)
body: <p><strong>Updated to give better explanation:</strong></p>
  
  <p>I'm in the process of trying to create a highscores feature for my clan on a game called runescape but i don't know how to sort the leaderboard by "total level"</p>
  
  <p><a href="http://mcbuffalo.com/playground/osrs/" rel="nofollow noreferrer">Working Demo without sorting by total level</a></p>
  
  <p>For example silenthawk should be top because he has a total of 1,941. I have a table called rsusers with the columns <strong>id, rank and playername</strong> </p>
  
  <p>I'm doing a sql query to get all the people from the clan and then getting the highscores off the runescape website by using a page called oldschoolhiscore.php that i found on github (<a href="https://github.com/tyler-shaw/osrs-hiscores" rel="nofollow noreferrer">linked here</a>) - I think all i have to do is edit this page to sort by the 'total level' but i'm not sure?</p>
  
  <p>Here is very stripped down and simple demo and code:</p>
  
  <p><a href="http://mcbuffalo.com/playground/osrs/basic.php" rel="nofollow noreferrer">Demo here</a></p>
  
  <p>Code:</p>
  
  <pre><code>        &lt;?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);  
  
  
      ?&gt;  
  
  
  
          &lt;table class="table table-striped table-list-search"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Name&lt;/td&gt;
                      &lt;td&gt;Level&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
  
              &lt;tbody&gt;
  
  
              &lt;?php  
  
              while ($row = mysql_fetch_assoc($rs_result)) { 
  
  
  
                  $hs = new OldSchoolHiscore($row['username']);
  
  
                  $total_level = $hs-&gt;getSkillLevel('overall');
  
                  echo "&lt;tr&gt;";
  
                  echo "&lt;td&gt;".$row['username']."&lt;/td&gt;";
                  echo "&lt;td&gt;$total_level&lt;/td&gt;";
  
  
                  echo "&lt;/tr&gt;";
  
  
  
  
              }
  
              ?&gt;  
  
      &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>SQL</p>
  
  <pre><code>    INSERT INTO rsusers 
  (username, clanrank)
  VALUES 
  ('Dwh_Hunters', 'lieutenant'),
  ('SilentHawk', 'general'),
  ('Sir Novel', 'lieutenant'),
  ('Ryuk Yagami', 'general');
  </code></pre>