我的本地计算机上有一个wamp服务器。 我能够在浏览器中使用PHP脚本获取数据;
$mysqli = new mysqli("localhost", "root", "", "q");
/* Select queries return a resultset */
if ($result = $mysqli->query("select * from Institution LIMIT 10")) {
printf("Select returned %d rows.<br />", $result->num_rows);
}
while ($row = $result->fetch_row()) {
printf("idInstitution is %s, %s, %s, %s<br />", $row[0], $row[3], $row[8], $row[9]);
$output[] = $row;
}
$result->close();
print(json_encode($output));// this will print the output in json
mysqli_close($mysqli);
在我的浏览器上输入以下网址 http://localhost/q/myfile1.php 输出如下:
浏览器输出
Select returned 4 rows.
idInstitution is 4, ???? ?????, 60, True
idInstitution is 5, ???? ?????, 0, True
idInstitution is 6, ????? ?????, 45, False
idInstitution is 7, test, , False
[
["4","0","0","???? ????",null,null,null,null,"60","True",null],
["5","0","0","???? ?????",null,null,null,null,"0","True",null],
["6","0","0","????? ?????",null,null,null,null,"45","False",null],
["7","0","0","test",null,null,null,null,null,"False",null]
]
我希望能够在我的Android应用程序中获取最后一行($ output)。 我该怎么做?
答案 0 :(得分:0)
问题解决了 - 看我的编辑。我只需要将http代码移动到后台线程。