I want to write a wordpress Comment system by myself. Of course, the wordpress data table structure is used. However, there is a bit of doubt about how to find this level. The database structure is as follows, where the id is automatically generated. postid indicates the article where the comment is made, and approved indicates whether the comment has passed...
I want to write a wordpress Comment system by myself. Of course, the wordpress data table structure is used.
However, there is a bit of doubt about how to find this level.
The database structure is as follows:
The id is automatically generated, the postid indicates the article where the comment is located, the approved indicates whether the review is performed (0 indicates no), and the parent indicates the parent Id of the comment (reply to the comment ), content is content.
The normal output result should be
Here, how can I write php to achieve this effect? I don't know the concept of data structure calling in my mind. Its Process
The first is to call this post with the postid of 99, so that the database content is the same as my first one.
Next, I want to output comments with a level of 0, but when will other levels be inserted?
Reply content:
I want to write a wordpress Comment system by myself. Of course, the wordpress data table structure is used.
However, there is a bit of doubt about how to find this level.
The database structure is as follows:
The id is automatically generated, the postid indicates the article where the comment is located, the approved indicates whether the review is performed (0 indicates no), and the parent indicates the parent Id of the comment (reply to the comment ), content is content.
The normal output result should be
Here, how can I write php to achieve this effect? I don't know the concept of data structure calling in my mind. Its Process
The first is to call this post with the postid of 99, so that the database content is the same as my first one.
Next, I want to output comments with a level of 0, but when will other levels be inserted?
Isn't this a typical tree structure? Just flatten it into the array.
Postid is used to make it possible for you to query each node separately.
As for how to insert it, if you plan to insert it at a time, it will be related to the code of the rendering template. The focus is on your html and css.
It can also be divided into two queries: first, the normal rendering page only has a level-1 comment, and then fill in the supplementary information in an ajax query (Baidu post it ).
However, the paging issue is troublesome.
Like zhihu, the complexity is reduced as much as possible. Of course, zhihu has no center floor and only one reply XXX. This implementation is much simpler and there is no need to worry about paging.