Jump to content

[SOLVED] How do you limit results?


kjtocool

Recommended Posts

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

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"; ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.