使用php mysql的线程评论

时间:2015-09-04 07:23:37

标签: php mysql

我有此表用于插入评论数据:(评论)

|id|message|timestamp|approved|parent_id|name|email|

此表用于评论的插入评论:(评论)

|id|cid|review_field1|review_field2|review_field3|...

php函数:

function _comments_($id,$type){
    $DB = mySqli::f("SELECT id,name,email,message,timestamp,review_field_1,review_field_2,review_field_3  FROM " . NEWS_COMMENTS . " LEFT JOIN " . NEWS_REVIEWS . " ON " . NEWS_COMMENTS . ".id = " . NEWS_REVIEWS . ".cid WHERE 
    pid = ? AND type = ? AND approved = 1 ORDER BY timestamp DESC LIMIT 12", $id, $type);

        foreach($DB as $row){
         $commentdata[] = $row;
        }
    return $commentdata;
}

结果:

<?PHP
$comments_list = _comments_('125','news');
    foreach($comments_list as $row):
?>

        /// HTML tags
<?PHP 
    $endforeach;
?>

这对我有用,并显示每条评论的评论和评论列表。

现在我需要为每条评论显示线程评论parent)。

我该如何显示线程评论?!

注意:对于家长评论,我不发送评论。

0 个答案:

没有答案