prepare("SELECT * FROM surveys WHERE id = ?"); $survey_stmt->execute([$survey_id]); $survey = $survey_stmt->fetch(); if (!$survey) { $error_message = "The requested survey could not be found."; } else { // Fetch questions and their options $questions_stmt = $pdo->prepare("SELECT * FROM questions WHERE survey_id = ? ORDER BY id ASC"); $questions_stmt->execute([$survey_id]); $questions = $questions_stmt->fetchAll(); } } catch (PDOException $e) { $error_message = "A database error occurred."; // In a real app, you would log the detailed error: error_log($e->getMessage()); } } ?>