分类名不能为空'; } else { $s = db()->prepare("INSERT INTO categories (name, slug) VALUES (?,?)"); $s->execute([$name, $slug]); header("Location: category.php?ok=1"); exit; } } if (isset($_GET["del"])) { $cid = (int)$_GET["del"]; db()->prepare("UPDATE articles SET category_id=NULL WHERE category_id=?")->execute([$cid]); db()->prepare("DELETE FROM categories WHERE id=?")->execute([$cid]); header("Location: category.php?deleted=1"); exit; } $list = db()->query("SELECT c.*, (SELECT COUNT(*) FROM articles a WHERE a.category_id=c.id) AS cnt FROM categories c ORDER BY c.id DESC")->fetchAll(); ?>

分类管理

删除成功

新增分类

ID名称别名文章数操作