prepare("DELETE FROM comments WHERE id=?")->execute([$cid]); header("Location: comment.php?deleted=1"); exit; } $page = isset($_GET["page"]) ? max(1,(int)$_GET["page"]) : 1; $per = 15; $total = (int)db()->query("SELECT COUNT(*) FROM comments")->fetchColumn(); $pages = max(1,(int)ceil($total/$per)); $page = min($page,$pages); $off = ($page-1)*$per; $stmt = db()->prepare("SELECT cm.*, a.title AS atitle FROM comments cm LEFT JOIN articles a ON a.id=cm.article_id ORDER BY cm.created_at DESC LIMIT ? OFFSET ?"); $stmt->bindValue(1,$per,PDO::PARAM_INT); $stmt->bindValue(2,$off,PDO::PARAM_INT); $stmt->execute(); $list = $stmt->fetchAll(); ?>
| ID | 评论内容 | 昵称 | 文章 | 时间 | 操作 |
|---|---|---|---|---|---|
| 暂无评论 | |||||