jj20051 Posted October 7, 2011 Share Posted October 7, 2011 Alright so I have some code for pagination... the problem is on the middle pages it will display double the number of results... (IE if its supposed to display 5, it displays 10) // Number of messages per page: $user_message_number = 5; $page = $_GET['page']; if($page <= 1){ $low = 0; $high = $user_message_number; } else { $low = ($page - 1) * $user_message_number; $high = $page * $user_message_number; } $messages = mysql_query("SELECT * FROM messages WHERE recipient='$user_id' ORDER BY id DESC LIMIT $low, $high") or die(mysql_error()); while($pull_messages = mysql_fetch_array($messages)) { // Displays content } That's all of the code that would directly effect the outcome... Any thoughts/comments/suggestions are greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/248606-help-debuging-limit/ Share on other sites More sharing options...
Buddski Posted October 7, 2011 Share Posted October 7, 2011 MySQL LIMIT isnt used in a 'show record 5 upto record 10' way. It is more of a 'starting from 5 show 5 records.' Having said that, you only need to figure out what page number you are upto and find the starting record, your $high variable should be $user_message_number $messages = mysql_query("SELECT * FROM messages WHERE recipient='$user_id' ORDER BY id DESC LIMIT $low, $user_message_number") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/248606-help-debuging-limit/#findComment-1276689 Share on other sites More sharing options...
jj20051 Posted October 9, 2011 Author Share Posted October 9, 2011 Thank you, I misunderstood exactly how it worked... That fixed it thanks Quote Link to comment https://forums.phpfreaks.com/topic/248606-help-debuging-limit/#findComment-1277334 Share on other sites More sharing options...
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.