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