Gem Posted March 17, 2012 Share Posted March 17, 2012 Hi guys, Was wondering if someone could help me with a query. Here is my table structure: commID int(11) postID int(4) replyto int(6) depth int(2) timestamp int(11) name varchar(100) email varchar(100) comment text So what I'm trying to get is the comments in order. The order I need is: comment 1 - parent comment 2 - parent comment 5 - reply to comment 2 comment 6 - another reply to comment 2 comment 7 - reply to comment 6 which is a reply to comment 2 comment 3 - parent comment 4 - reply to comment 3 and so on. There is no limit to how many levels of children there can be per parent. I'm hoping this makes sense :S Can you help? Many thanks Gem Quote Link to comment Share on other sites More sharing options...
Gem Posted March 17, 2012 Author Share Posted March 17, 2012 I forgot to say, I'm struggling because I need to paginate the comments. I need to page only at a parent, i.e not splitting child comments over seperate pages (planning to use js to show/hide the replies) so I'm wanting like say 5 parent comments, plus all their children per page. This is why I'm looking for a query to put them in the right order ... Quote Link to comment Share on other sites More sharing options...
fenway Posted March 18, 2012 Share Posted March 18, 2012 Then why not get all the parents first, then a second query to get their children? Or at least process the results sepearetly? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.