pengu Posted July 17, 2009 Share Posted July 17, 2009 I'll explain a bit better, I have a user database with 50 users in it for example, they're ordered by some sort of ranking. I only want to display 10 per page. And I'd like a ">>" next page kind of thing. Could this be achieved by using MySQL to do a COUNT of id's or usernames (doesn't really matter)? And then could I do use LIMIT to display the next 10 and the next 10 on the page? Hopefully this makes sense. id rank 1 1 7 2 3 3 - Page 2 >> Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/ Share on other sites More sharing options...
smerny Posted July 17, 2009 Share Posted July 17, 2009 use LIMIT 10; and you can use $_GET in the url for next page to find the start (www.somesite.com/somepage.php?start=1) for example Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/#findComment-876841 Share on other sites More sharing options...
pengu Posted July 17, 2009 Author Share Posted July 17, 2009 use LIMIT 10; and you can use $_GET in the url for next page to find the start (www.somesite.com/somepage.php?start=1) for example Can you be more specific with LIMIT is what I mean and you'd make the '10' a variable? somepage.php?start=1 $start = $_GET['start']; $sql = "BLA BLA BLA LIMIT 0, ".$start.""; See that kind of thing,but changing what the limits are, depending on those variables. Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/#findComment-876847 Share on other sites More sharing options...
immanuelx2 Posted July 17, 2009 Share Posted July 17, 2009 what you are looking to do is called "pagination" I would google "php pagination" there should be a tutorial somewhere out there (maybe even on here?) Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/#findComment-876849 Share on other sites More sharing options...
smerny Posted July 17, 2009 Share Posted July 17, 2009 LIMIT ".$start.", 10 but yea there are lots of them out there, here is one that came up on google and looks good http://www.phpeasystep.com/phptu/29.html Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/#findComment-876850 Share on other sites More sharing options...
pengu Posted July 17, 2009 Author Share Posted July 17, 2009 My theory was correct. Thanks for your help guys. Do a COUNT to get total number, do some maths and bam! LIMIT $a, $b Quote Link to comment https://forums.phpfreaks.com/topic/166272-phpmysql-multiple-pages/#findComment-876856 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.