Select Option'; foreach ($subjectArray as $i) { $subject_name = getFieldFromTable('subject_name', 'subjects', 'subject_id', intval($i)); // Ensure the ID is an integer error_log("check_subject_name : ".$subject_name); if ($subject_name) { $options .= ""; // Use double quotes for HTML } } // Return the course name and options echo json_encode([ 'course_name' => $course_name, 'options' => $options ]); } ?>