= '2023-10-04 00:00:00' and (recommended_tests_new !='' and recommended_tests_new is not null);"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_assoc($result)) { $appointment_id = $row['appointment_id']; $tests = explode(",", $row['recommended_tests_new']); $test_ids = []; for ($i = 0; $i < count($tests); $i++) { $test_id = getFieldFromTable('section_id', 'checkup_form_section', 'section_name', trim($tests[$i])); if (trim($test_id) != '' && trim($test_id) != null) { array_push($test_ids, $test_id); } } if (count($test_ids) > 0) { $corrected_data = implode(",", $test_ids); $update = "update employee_appointment set recommended_tests_new = '" . $corrected_data . "' where appointment_id = '" . $appointment_id . "'"; error_log("correction query " . $update); if (!$result_update = mysqli_query($conn, $update)) { error_log("error while correcting the data " . mysqli_error($conn)); } } }