可能重复:
我希望创建一个嵌套的评论系统-我意识到,这已经涵盖在以前的所以和网络,但我似乎不能得到任何正确的工作。
鉴于下面的表结构(我已经创建):
CREATE TABLE IF NOT EXISTS `comments` (
`commentid` int(11) NOT NULL auto_increment,
`newsid` int(11) NOT NULL,
`body` text NOT NULL,
`added` int(11) NOT NULL,
`parent` int(11) default NULL,
PRIMARY KEY (`commentid`)
)我怎样才能以一种线程的方式发表评论呢?我正在寻找一个MySQL的PHP解决方案。我意识到父母持有评论的批注(家长)。
发布于 2011-04-19 01:46:03
保存答复时,将父id分配给要答复的回复的注释id。
生成HTML时,递归地打印任何父类的子注释。
发布于 2011-04-19 01:46:23
Row 1: commentId=1;parent=0 (this is a parent comment)
Row 2: commentId=2; parent=1 (this means its a child of comment 1)
Row 3: commentid=3; parent=2 (this is a child of 2nd comment)
Row 4: commentid=4; parent=0 (this is the "fresh second" comment) 有道理吗?
https://stackoverflow.com/questions/5710700
复制相似问题