http://www.cookyx.com/leaderboards.php
If you scroll through the next pages, you'll see the rank numbers stay the same while the others change.
How do I fix this so it shows correctly?
code: (I am using a pagination script)
<?php
include "config.php";
session_start();
switch($_GET
)
{
default:
$sql = "SELECT COUNT(*) FROM `members`";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$msgs = mysql_query("SELECT * FROM `members`") or die(mysql_error()); //get all the
$a = mysql_fetch_array($msgs);
$numxrows = mysql_num_rows($msgs);
$numrows = $numxrows;
$rowsperpage = 12;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
} // end if
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
} // end if
if ($currentpage < 1) {
$currentpage = 1;
} // end if
$offset = ($currentpage - 1) * $rowsperpage;
$sql = "SELECT * FROM `members` WHERE `userlevel` = '2' OR `userlevel` = '4' ORDER BY `cookies` DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
echo "<style>
tr#tb {
background:#BDB8A1;
color:#7A7357;
font-weight:bold;
}
td#d {
padding:5px;
}
</style><table align='center'><tr id='tb'><td id='d' style='width:50px;text-align:center;'>Rank</td><td id='d' style='width:120px;text-align:center;'>Username</td><td id='d' style='width:70px;text-align:center;'>Cookies</td></tr>"; //table start for hiscores
$fetch = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '2' OR `userlevel` = '4' ORDER BY `cookies` DESC LIMIT 0,25"); //grabs exp and orders it by - highest at top and lowest at bottom
$i = 1;
$class1 = 'background:#D7D3BF;color:#928C72;font-weight:bold;';
$class2 = 'background:transparent;color:#928C72;font-weight:bold;';
$class = $class1;
while ($pets = mysql_fetch_assoc($result)) {
echo ("<tr style='$class'><td style='width:50px;text-align:center;'>$i</td><td style='width:120px;text-align:center;'><a href='http://cookyx.com/profile/$pets[id]'>$pets[username]</a></td><td style='width:70px;text-align:center;'>$pets[cookies]</td></tr>"); //the hiscore main table
$i++;
if($class == $class1){
$class = $class2;
}else{
$class = $class1;
}
}
$range = 3;
echo "</table><div id='normal'>"; //end table
/****** build the pagination links ******/
// range of num links to show
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><img src='http://cookyx.com/icons/resultset_first.png' border='0'></a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><img src='http://cookyx.com/icons/resultset_previous.png' border='0'></a> ";
} // end if
// loop to show links to range of pages around current page
for ($x = (($currentpage - $range) - 1); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'><img src='http://cookyx.com/icons/resultset_next.png' border='0'></a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'><img src='http://cookyx.com/icons/resultset_last.png' border='0'></a> ";
} // end if
/****** end build pagination links ******/
echo "</div>";
break;
}
?>