exec("CREATE TABLE IF NOT EXISTS `treatment_categories` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `hospital_id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `description` TEXT, FOREIGN KEY (`hospital_id`) REFERENCES `hospitals`(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['category_name'])) { $categoryName = trim($_POST['category_name']); $description = trim($_POST['description']); if (!empty($categoryName)) { $stmt = $pdo->prepare("INSERT INTO treatment_categories (hospital_id, name, description) VALUES (:hospital_id, :name, :description)"); $stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT); $stmt->bindParam(':name', $categoryName, PDO::PARAM_STR); $stmt->bindParam(':description', $description, PDO::PARAM_STR); if ($stmt->execute()) { $message = '
Treatment category added successfully!
'; } else { $message = '
Failed to add category.
'; } } else { $message = '
Category name is required.
'; } } // Fetch existing categories for this hospital $stmt = $pdo->prepare("SELECT * FROM treatment_categories WHERE hospital_id = :hospital_id ORDER BY name"); $stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT); $stmt->execute(); $categories = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $message = '
Database error: ' . $e->getMessage() . '
'; $categories = []; } ?> Manage Treatment Categories - Medicaltour

Manage Treatment Categories

Add New Category
Your Treatment Categories

You have not added any treatment categories yet.