PHP Comment Reply Solution

Source: Internet
Author: User
Problem:

I know the problem is very, very elementary. I also searched a lot of posts, but it was quite troublesome, or I was not able to achieve enough.
The problem is this:
I am practicing blogging system, to implement the comment reply function, the request is not high, the guest comments, bloggers reply to comments, can not reply again, only a layer of relationship: Comment-reply. It's so simple.
The data table structure of the methods on the Internet is mostly as follows:

ID: Comment Idpid: Reply to comments idcontent: Comment Content

I want to know how to find a record of a reply when there are several lines between the record of the comment and the record of the reply, such as:

ID pid1  1  //reply and comment separated by several lines 4  0

This problem is very difficult to solve in the SQL sort reorganization. Help the Great God, thank you very much
Solution:
Fixed level two stories
This statement is learned with MySQL moderators

SELECT * from ' comment ' ORDER by if (PID=0,ID,PID) ASC

The above is the content of the PHP comment reply solution, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

Related articles:

How does the PHP comment reply to infinite pole nesting be implemented? Have written the basic code, look forward to expert doubts

Use the PHP wireless level to implement the comment reply function in categories

Using JS to achieve the perfect imitation QQ space comment reply effect

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