prepare("SELECT id FROM training_sessions WHERE id = ? AND coach_id = ?"); $stmt->execute([$session_id, $coach_id]); $session = $stmt->fetch(); if ($session) { // The ON DELETE CASCADE on the training_session_drills table will handle deleting the links. $stmt = $pdo->prepare("DELETE FROM training_sessions WHERE id = ?"); $stmt->execute([$session_id]); } // Redirect back to the list with a status message header('Location: training_sessions.php?status=deleted'); exit(); ?>