Implement Message Board layering using html-php Recursion

Source: Internet
Author: User
My idea is to create a message table with an id field and a pid field. If it is the first-level message pid field, it is set to 0, otherwise, store the id value of the previous layer. Recursively obtain the depth of each line When retrieving data. Add spaces before the output according to the depth ....

Functions similar to the above

My idea is to create a message table with an id field and a pid field. If it is the first-level message pid field, it is set to 0. Otherwise, it stores the previous layer of id value. Recursively obtain the depth of each line When retrieving data, and add spaces before the output according to the depth.

This is probably the case for tables.

Id pid content
1 0 messages 1
2 0 messages 2
3 0 messages 3
4 3 messages 4
5 4 leave a message 5

It seems that the page flip function is not very easy to do. I don't know where to improve it?
I don't know if there are any other good methods. I hope to give me some ideas!

Reply content:

Functions similar to the above

My idea is to create a message table with an id field and a pid field. If it is the first-level message pid field, it is set to 0. Otherwise, it stores the previous layer of id value. Recursively obtain the depth of each line When retrieving data, and add spaces before the output according to the depth.

This is probably the case for tables.

Id pid content
1 0 messages 1
2 0 messages 2
3 0 messages 3
4 3 messages 4
5 4 leave a message 5

It seems that the page flip function is not very easy to do. I don't know where to improve it?
I don't know if there are any other good methods. I hope to give me some ideas!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.