title: Multi-tiered Comment Replies: Display and Storage
body: <p>So I'm trying to create a comment system in which you can reply to comments that are already replies (allowing you to create theoretically infinite threads of replies).  I want them to display in chronological order (newest on top), but of course the replies should be directly underneath the original comment.  If there are multiple comments replying to the same comment, the replies should also be in chronological order (still underneath the original comment).  I also want to limit the number of comment groups (a set of comments with a single comment that is not a reply at all) to, say, 25.  How should I set up the MySQL table, and what sort of query would I use to extract what I want?</p>
  
  <p>Here's a simplified version of my DB:
  <code>ID</code> int(11) NOT NULL AUTO_INCREMENT,
  <code>DatePosted</code> datetime NOT NULL,
  <code>InReplyTo</code> int(11) NOT NULL DEFAULT '0',</p>
  
  <p>Sorry if this is kind of confusing, I'm not sure how to word it any differently.  I've had this problem in the back of my mind for a couple months now, and every time I solve one problem, I end up with another... </p>