$question) { $stq_title = isset($question['stq_title']) ? trim($question['stq_title']) : ''; $stq_description = isset($question['stq_description']) ? trim($question['stq_description']) : ''; $stq_type = isset($question['stq_type']) ? trim($question['stq_type']) : 'text'; $stq_required = isset($question['stq_required']) ? 1 : 0; $stq_options = ''; if (!$stq_title) { continue; // 제목이 없는 질문은 건너뛰기 } // 옵션 처리 (객관식 질문인 경우) if (in_array($stq_type, ['radio', 'checkbox', 'select']) && isset($question['options'])) { $options = array_filter($question['options'], function($option) { return trim($option) !== ''; }); if (!empty($options)) { $stq_options = json_encode(array_values($options), JSON_UNESCAPED_UNICODE); } } $sql = "INSERT INTO survey_template_questions (st_id, stq_order, stq_type, stq_title, stq_description, stq_required, stq_options, stq_created_at) VALUES ('$st_id', '".($order + 1)."', '".sql_real_escape_string($stq_type)."', '".sql_real_escape_string($stq_title)."', '".sql_real_escape_string($stq_description)."', '$stq_required', '".sql_real_escape_string($stq_options)."', NOW())"; sql_query($sql); } $message = $mode == 'insert' ? '템플릿이 생성되었습니다.' : '템플릿이 수정되었습니다.'; alert($message, 'template_list.php'); ?>