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 Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/ 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571389 Share on other sites More sharing options...
kpetsche20 Posted June 22, 2008 Author Share Posted June 22, 2008 What goes in the value spot? Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571392 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571393 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) Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571395 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? Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571396 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 Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571399 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571404 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"; Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571407 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 Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571410 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571416 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571417 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571418 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571420 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 Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571421 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571447 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. Link to comment https://forums.phpfreaks.com/topic/111311-how-do-i-limit-results-from-a-mysql-to-10-per-page/#findComment-571675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.