// Get the slug from the URL $slug = $_GET['sub'] ?? $_GET['slug']; // Find the category in the database by slug $stmt = $pdo->prepare("SELECT * FROM categories WHERE slug = ?"); $stmt->execute([$slug]); $category = $stmt->fetch(); // Now proceed with your existing logic to show products/sub-categories