如果没有更多要加载的条目,在mysql查询中添加if语句?

sorry for the convoluted question. The issue I'm having is is there a way to add a conditional in the form of an if statement or similar function to check if when a mysql query is run, if there aren't any rows/data entries left?

Basically how my site is set up is I've got a Twitter-esque blog page. On the site is displayed a bunch of posts descending by date added, which are all taken from a database. By default the page starts off displaying only 8 posts, with a "Click for more" button which then runs an Ajax function, loading in 5 more database entries, which you can keep clicking to load in more posts. Is there any way to check if there aren't any more data entries available? Basically what I want to do is have the "click for more" button to disappear when all of the database entries have been displayed/queried.

Searching around hasn't done me any good, thanks for any help! :D

Do something like this (Note this is untidy, but it's simply an example):

I'm assuming you're using PHP and AJAX to fetch new posts.

$nPosts = mysql_query("SELECT COUNT(ID or whatever your auto-increment field is called) FROM Posts");

$nPosts = mysql_fetch_array($nPosts);


if ($nPosts[0] == $postsThatAreBeingDisplayed)
{
    (Tell AJAX to disable the button)
}
else
{
    (Pass AJAX back 5 more posts)
}