0) { $row = mysqli_fetch_assoc($result); $data = $row; // Store the row data // Get the training program ID based on the batch ID // $training_program_id = getFieldFromTable('training_program_id', 'training_batch_master', 'batch_id', $row['batch_id']); // Get the course name based on the training program ID $subject_name = getFieldFromTable('subject_name', 'subjects', 'subject_id', $row['subject_id']); $data['subject_name'] = $subject_name; // Set success status $data['status'] = 200; // Indicate successful retrieval } else { $data['status'] = 404; // Use a more appropriate status code for not found $data['message'] = "Data not found!"; } // Return the response as JSON header('Content-Type: application/json'); // Set content type for JSON response echo json_encode($data); ?>