prepare("SELECT image FROM categories WHERE id = ?"); $stmt_img->execute([$cat_id]); $img_name = $stmt_img->fetchColumn(); $stmt = $pdo->prepare("DELETE FROM categories WHERE id = ?"); $stmt->execute([$cat_id]); // Delete image if not empty and not matching default patterns if (!empty($img_name) && file_exists(__DIR__ . '/../assets/images/' . $img_name) && strpos($img_name, 'cat_') === false) { @unlink(__DIR__ . '/../assets/images/' . $img_name); } $msg = 'Category deleted successfully.'; } catch (Exception $e) { $msg = 'Failed to delete category: ' . $e->getMessage() . '. (Hint: Ensure no products remain assigned to this category.)'; $msg_type = 'danger'; } } // Fetch all categories try { $stmt = $pdo->query("SELECT c.*, COUNT(p.id) as product_count FROM categories c LEFT JOIN products p ON c.id = p.category_id GROUP BY c.id ORDER BY c.id ASC"); $categories = $stmt->fetchAll(); } catch (Exception $e) { $categories = []; } ?>

Catalog Categories

Manage classifications, arched landing images, and routing slugs.

Add Category
No categories exist. Create your first category to classify collection assets!
Preview Category Name Slug Reference Assigned Products Actions
Category Preview
Products