Jaaaacccckkk Posted July 6, 2013 Posted July 6, 2013 (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 July 6, 2013 by Jaaaacccckkk Quote
jcvenom Posted July 15, 2013 Posted July 15, 2013 i have no idea whats wrong can you post the full file Quote
rockwood Posted July 18, 2013 Posted July 18, 2013 $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 Quote
jcvenom Posted July 18, 2013 Posted July 18, 2013 $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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.