Jump to content

Display 20 Results Every Page - SQL


oliverj777

Recommended Posts

Hello,

 

I have an online scoreboard, and right now it just displays all the players from highest score to lowest score. How would I be able to only display 20 players, and have a 'next' button that then displays the next 20 players down the line of scores?

 

So, below is the code I use to display my score table:

 

 

mysql_connect("localhost", "user", "pass");
mysql_select_db("data");

$fetch = "SELECT * FROM highscores ORDER BY score desc";
$result = mysql_query($fetch);
$grab = $_POST["grabUser"];


$count = 1;
while($row = mysql_fetch_array($result)){
        echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr>";
echo "<td width=\"30\" align=\"left\" class=\"scoreBoard-content\">".$count."</td>";
echo "<td width=\"50%\" align=\"left\" class=\"scoreBoard-content\">".$row['player']."</td>";
echo "<td align=\"right\" class=\"scoreBoard-content\">".$row['score']."</td>";
echo "<td width=\"60\" align=\"right\" class=\"scoreBoard-content\">";
        $count ++;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.