A
A
Alexander2015-07-29 16:42:07
PHP
Alexander, 2015-07-29 16:42:07

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

3 answer(s)
A
Alexander N++, 2015-07-29
@up_sweep

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

I
IceJOKER, 2015-07-29
@IceJOKER

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

A
Art. Ku., 2015-09-23
@kukaew

I understand that there is no good solution here. Usually they make a limit for the 1st level, and the answers are hidden and loaded on click for a specific comment of the 1st level. How did you solve the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question