Answer the question
In order to leave comments, you need to log in
How to paginate tree comments?
Hello, friends. I have on the site the output of comments in a tree view with a nesting level of 2 ..
table of comments:
id parent text ip date, etc.
1 0
fy 2 1 fyv
3 1 fff I
pull all the comments with one request, push them into the array (parent>0=indented) and display them on the site through recursion.
What's the smartest way to do pagination?
I would be very grateful for your help..
Answer the question
In order to leave comments, you need to log in
Trees in mysql are not very good for pagination.
Do you need such a method?
--111
---222
===222
---222
--222 Is there another page followed
by buttons
--2323
--23233
or to end root comments?
The first option is done by 1 NestedSet request where each comment is a new tree.
For the second option 2 requests.
I don't really like tree-like comments, I prefer the Facebook / VKontakte system based on dialogues
www.9lessons.info/2013/05/message-conversation-dat...
Same as normal comments O_O
Or if you don't want to separate parent from child , then count only those comments that have parent = 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question