Jump to content

Query help please?


Gem

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/259162-query-help-please/
Share on other sites

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 ...

Link to comment
https://forums.phpfreaks.com/topic/259162-query-help-please/#findComment-1328595
Share on other sites

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.