0) { while ($row = mysqli_fetch_assoc($result)) { $data = $row; } } else { $data['status'] = 200; $data['message'] = "Data not found!"; } } else { $query = "select * from habits where upper(habit)= upper('$name') "; error_log($query); if (!$result = @mysqli_query($conn, $query)) { exit(mysqli_error($conn)); } if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { array_push($data, $row); } } else { $data['status'] = 200; $data['message'] = "Data not found!"; } $data['count'] = mysqli_num_rows($result); } // error_log(print_r($data, true)); echo json_encode($data);