prepare("SELECT * FROM categories WHERE id=?"); $c->execute([$id]); $cat = $c->fetch(); if (!$cat) { header("Location: " . SITE_URL . "index.php"); exit; } $pageName = "category"; $curCategory = $id; $pageTitle = $cat["name"]; record_visit("category/" . $id); $perPage = 5; $st = db()->prepare("SELECT COUNT(*) c FROM articles WHERE category_id=? AND status=?"); $st->execute([$id,"published"]); $pg = paginate((int)$st->fetch()["c"], isset($_GET["page"])?(int)$_GET["page"]:1, $perPage); $stmt = db()->prepare("SELECT a.* FROM articles a WHERE a.category_id=? AND a.status=? ORDER BY a.created_at DESC LIMIT ? OFFSET ?"); $stmt->bindValue(1,$id,PDO::PARAM_INT); $stmt->bindValue(2,"published",PDO::PARAM_STR); $stmt->bindValue(3,$pg["perPage"],PDO::PARAM_INT); $stmt->bindValue(4,$pg["offset"],PDO::PARAM_INT); $stmt->execute(); $articles = $stmt->fetchAll(); require_once __DIR__ . "/includes/header.php"; ?>

分类下的文章
该分类暂无文章
'">
次阅读

1) { ?>