admin管理员组文章数量:1125966
I'm working on creating a comment system for an event plugin I am creating. I have the commenting and replies forms working correctly, I just need help with writing them out to the site. I am on MySql 5.6 so can't use a recursive query.
Comment Table
id - int
eventid - int
userid - int
content - text
datesaved - datetime
parentid - int
PHP/SQL What I currently have to display the comments. This doesn't display the replies, that's what I need help with.
$commentsql = $wpdb->get_results("SELECT comm.id as id, comm.eventid as eventid, comm.userid as userid, comm.content as comment, comm.datesaved as date, users.meta_value as fname, users2.meta_value as lname
FROM " . $wpdb->prefix . "cmc_communitybb_event_comments as comm
inner join " . $wpdb->prefix . "usermeta as users on comm.userid = users.user_id and users.meta_key = 'first_name'
inner join " . $wpdb->prefix . "usermeta as users2 on comm.userid = users2.user_id and users2.meta_key = 'last_name'
where comm.eventid=$eventid and comm.parentid is null order by comm.datesaved desc");
foreach ($commentsql as $comment) {
//code to display comments goes here
}
本文标签:
版权声明:本文标题:php - Help writing out comments and replies 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736664928a1946612.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论