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
https://forums.phpfreaks.com/topic/241091-display-20-results-every-page-sql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.