0) { while ($row = @mysqli_fetch_assoc($result)) { $id_max = $row['id']; } } $query = "select * from covid_patient_staying where id='".$id_max."'"; //echo $query; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { while ($row = @mysqli_fetch_assoc($result)) { $data=$row; } } } if($data==null) { $data['status'] = 200; $data['message'] = "Data not found!"; } echo json_encode($data); ?>