kjtocool Posted December 18, 2007 Share Posted December 18, 2007 Let's say I have a query like this: <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID"; ?> How do I modify that query so that it: A) Returns only the first 10 results. B) Returns only results 11 through 20. Link to comment https://forums.phpfreaks.com/topic/82209-solved-how-do-you-limit-results/ Share on other sites More sharing options...
kjtocool Posted December 18, 2007 Author Share Posted December 18, 2007 I believe this is the answer, if anyone can verify I'd appreciate it: A) <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID LIMIT 0,9"; ?> B) <?php $query = "SELECT user_ID, comment FROM Article_Comments WHERE article_ID = $article_ID ORDER BY comment_ID LIMIT 10,9"; ?> Link to comment https://forums.phpfreaks.com/topic/82209-solved-how-do-you-limit-results/#findComment-417774 Share on other sites More sharing options...
kopytko Posted December 18, 2007 Share Posted December 18, 2007 Almost. A) limit 0, 10 B) limit 10,10 Link to comment https://forums.phpfreaks.com/topic/82209-solved-how-do-you-limit-results/#findComment-417802 Share on other sites More sharing options...
kjtocool Posted December 18, 2007 Author Share Posted December 18, 2007 So the second number starts at 1 and not 0? Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/82209-solved-how-do-you-limit-results/#findComment-417806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.