kpetsche20 Posted June 22, 2008 Share Posted June 22, 2008 How do I limit results from a MySQL to 10 per page. I'm not exactly sure how many values there are in the database but I know there over a few hundred Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted June 22, 2008 Share Posted June 22, 2008 $sql = "SELECT * FROM `table` WHERE `field` = 'value' LIMIT 10" LIMIT is what you need On another note -- if you want to do, say, the second 10, it's like this: $sql = "SELECT * FROM `table` WHERE `field` = 'value' LIMIT 10, 10" This means select rows, limit 10, start after the tenth, so you get 11, 12, 13, 14, 15, 16, 17, 18, 19 and 20. Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 What goes in the value spot? Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 I need all the results to display, i dont want to limit the number of pages. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted June 22, 2008 Share Posted June 22, 2008 Whatever you're getting from the database. If you don't want to filter it, you don't need that, and you can just use: SELECT * FROM `table` LIMIT 10 All the value bit does is select from table WHERE the field (field name) is equal to the value (value name) Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted June 22, 2008 Share Posted June 22, 2008 How do I limit results from a MySQL to 10 per page. I'm not exactly sure how many values there are in the database but I know there over a few hundred That sounds to me like you want to limit them? Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 i want to limit the values to 10 values per page, with an unlimited number of pages Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 $story = "SELECT * FROM stories WHERE name = '".$_GET['name']."' LIMIT 2"; That is what I have, it's not working though. Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 Ok I got it to work, but the problem I face now is how do I add in buttons so people can go to the next pages. $sql = "SELECT * FROM stories LIMIT 3"; Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 22, 2008 Share Posted June 22, 2008 Im going to direct you to a very good tutorial on pagination: http://www.phpfreaks.com/tutorial/basic-pagination There's no point in us typing out another tutorial for you on the forums; so take a look at that one Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 I was hoping to get an example of the correct code. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 22, 2008 Share Posted June 22, 2008 I was hoping to get an example of the correct code. There is an example of the correct code. On page 2 i believe. Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 It makes no sense to me, that's a insert code. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 22, 2008 Share Posted June 22, 2008 Perhaps you could try reading through the tutorial then? I'm sure if you had checked the next page/read a little, you would have noticed i was wrong and the code for the pagination is on page 3. Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 I dont have time to read 12 pages of something I dont really understand anyway i just need the code. Is it really that complex to where someone can't just write it out for me real fast Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted June 22, 2008 Share Posted June 22, 2008 Being rude probably won't help. If you want someone to write you code, hire a programmer. This is a website for learning PHP. If you read the tutorial, you might just learn something about pagination. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 22, 2008 Share Posted June 22, 2008 I was going to post a reply commenting on your attitude. But i wont waste my breath. Quote Link to comment 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.