Home  >  Article  >  Backend Development  >  PHP评论回复解决方法

PHP评论回复解决方法

PHP中文网
PHP中文网Original
2017-03-27 16:18:172856browse

问题:

我知道这个问题非常非常初级。。我也搜索了很多帖子,但是都相当麻烦,或者我能力不够无法实现。
问题是这样的:
我在练习写博客系统,要实现评论回复功能,要求不高,访客评论,博主回复评论,不能对回复再回复,只有一层关系:评论-回复。就这么简单。
网上的方法的数据表结构大多如下:

id:评论id
pid:回复的评论id
content:评论内容

我想知道,当评论的记录与回复的记录之间隔了若干行,要怎样找到回复的记录,比如:

id pid
1  0
2  0
3  1  //回复与评论隔了若干行
4  0

这个问题在SQL排序重组里好难解决啊。。求助大神,万分感谢
解决方案:
固定层级为两层好说
这语句是跟mysql版主学的

select * from `comment` order by if(pid=0,id,pid) asc

以上就是PHP评论回复解决方法的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!

相关文章:

关于php评论回复无限极嵌套如何实现?已写基本代码,期待高手解惑

使用php无线级别分门别类 实现评论回复功能

使用JS完美实现仿QQ空间评论回复特效

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn