简体   繁体   English

如何将Android连接到WAMP服务器

[英]how to connect android to wamp server

I have a wamp server on my local computer. 我的本地计算机上有一个wamp服务器。 I am able to get the data using PHP script in my browser; 我可以在浏览器中使用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);

On my browser I typed the following URL http://localhost/q/myfile1.php and the output is as follows: 在我的浏览器中,我输入了以下URL http://localhost/q/myfile1.php ,输出如下:

Browser output 浏览器输出

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]
]

I want to be able to get the last row ($output) in my android application. 我希望能够在我的android应用程序中获取最后一行($ output)。 How do I do it? 我该怎么做?

Problem solved - see my edit. 问题已解决-查看我的编辑。 All I needed is to move the http code to a background thread. 我需要做的就是将http代码移动到后台线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM