Creating your own Leaderboard / Highscores Easy and Free (PHP & MySQL) [UPDATED 2020]

You're viewing a single comment in a conversation. View all the comments
  • 2 Comments

  • Order by
  • Is there anyway for me to change the code so that is will give you the lowest scores as my game doesn't have a score but rather a speed run clock that goes up the longer you take to finish. So my "high scores" need to be the ones with the lowest values can you help me at all with where and what in the code I need to change?

    • Yes!

      Open 'getscores.php' and replace "ORDER BY score DESC" (scores are ordered DESCending - higher first then lower) with "ORDER BY score ASC" (scores will be ordered ASCending - lowest values first, then higher)

      // Retrieve data from database

      $sql = "SELECT *

      FROM scores

      ORDER BY score DESC // Replace 'DESC' with 'ASC'

      LIMIT 10"; // The 'LIMIT 10' part will only read 10 scores. Feel free to change this value