Need help with Query and Pagination

There are a couple of places on my website where I need to add the concept of Pagination (e.g. Member’s Inbox, Article Comments, etc)

First of all, I’m not really sure where to begin with doing Pagination?!

Secondly, I’m confused with how I would modify my Prepared Statements to allow for Pagination. :-/

Here is a snippet of a query which retrieves User Comments located below an Article…

	$q2 = 'SELECT AS member_id, m.username, AS comment_id, c.created_on, c.comment_no, c.body,
			FROM member AS m
			INNER JOIN comment AS c
			ON = c.member_id
			WHERE c.article_id = ?
			ORDER BY c.created_on';

	$stmt2 = mysqli_prepare($dbc, $q2);

	mysqli_stmt_bind_param($stmt2, 'i', $articleID);



If it turns out that people love (or hate) one of my Articles, and they leave 150 Comments below it…

1.) How exactly would I make it so that maybe only 15 Comments are shown at a time?

2.) More importantly, how would I modify my Prepared Statement to handle the dynamic nature of Pagination??

(In other words, I think I’d need some new variables in my Prepared Statement, so things couldn’t be hard-coded, right?)



Try use this Pagination Class - Script to paginate content, see example on that page.
Or test this Script comments with pagination, presented on this forum.