Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

I'm having a little problem with this piece of code. What i have is a page which lists every user in a game. I have them ranking from most ranked user, to least ranked. Now the problem. I have it so each user has a rank position next to their name. For example:

#1 user bill - 500 points

#2 user ben - 255 points

This works however, when i click next page, as i have limited it to showing 10 users a page, the rank position resets back to 1 - 10, instead of going 11 - 20.

I would be very grateful if somebody could help me!

 


#pagination

$limit = 10;
$query_count = "SELECT * FROM `users` WHERE `status` = 'Alive' ORDER by `rankpoints`";    
$result_count = mysql_query($query_count);    
$totalrows = mysql_num_rows($result_count); 

if(empty($page)){
$page = 1;
}
if($totalrows == "0"){$totalrows = "1";}
$limitvalue = $page * $limit - ($limit);  

$numofpages = $totalrows / $limit; 


$query_position = mysql_query("SELECT * FROM `users` WHERE `status` = 'Alive' ORDER by `rankpoints` DESC LIMIT $limitvalue, $limit");

$i = 0;
while ($find = mysql_fetch_object($query_position)){
$i++;
$position = "".$i." ";

echo"#$position";
echo"$find->username";

}
Edited by Jaaaacccckkk
  • 2 weeks later...
Posted
$posts_per_page = 10;
   $posts_topic = "number of users";
   $pages = ceil("total number of rows" / $posts_per_page);
   $st = isset($_GET['st']) ? $_GET['st'] : 0;
   if (isset($_GET['lastpost'])) {
       $st = ($pages - 1) * 10;
   }
   $pst = -10;
   print "Pages: ";
   for ($i = 1; $i <= $pages; $i++) {
       $pst += 20;
       print "<a href='pagename.php?viewusernumber={"current row id"}&st=$pst'>";
       if ($pst == $st) {
           print "<b>";
       }
       print $i;
       if ($pst == $st) {
           print "</b>";
       }
       print "</a> ";
       if ($i % 25 == 0) {
           print "<br />";
       }
   }

you should try something like this

Posted
$posts_per_page = 10;
   $posts_topic = "number of users";
   $pages = ceil("total number of rows" / $posts_per_page);
   $st = isset($_GET['st']) ? $_GET['st'] : 0;
   if (isset($_GET['lastpost'])) {
       $st = ($pages - 1) * 10;
   }
   $pst = -10;
   print "Pages: ";
   for ($i = 1; $i <= $pages; $i++) {
       $pst += 20;
       print "<a href='pagename.php?viewusernumber={"current row id"}&st=$pst'>";
       if ($pst == $st) {
           print "<b>";
       }
       print $i;
       if ($pst == $st) {
           print "</b>";
       }
       print "</a>*";
       if ($i % 25 == 0) {
           print "<br />";
       }
   }

you should try something like this

nice rockwood

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.   Paste as plain text instead

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