简体   繁体   中英

how to connect android to wamp server

I have a wamp server on my local computer. I am able to get the data using PHP script in my browser;

$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:

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. How do I do it?

Problem solved - see my edit. All I needed is to move the http code to a background thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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