0) { while ($row = mysqli_fetch_assoc($result)) { $data = $row['checkup_id']; } } error_log("Max checkup id " . $data); echo json_encode($data);