1.首先在library创建index_comments.lib文件, 2.然后index.php写一个方法: function get_comments($num) { $sql = 'SELECT * FROM ecs_comment '. ' WHERE status = 1 AND parent_id = 0 and comment_type=0 '. ' ORDER BY add_time DESC'; if ($num > 0) { $sql .= ' LIMIT ' . $num; } //echo $sql;