我在这里处理问题。我有我的PHP代码,它向我发送一个包含所有信息的用户数组。问题是:如何从Android访问所有这些信息? (不是一种丑陋的方式,我会在这里发帖)
任何帮助将不胜感激。
我的php文件
nameof()
我处理信息的方式:
<?php
$host = "mysql12.000webhost.com";
$user = "xxxx";
$password = "xxx";
$db = "xxxx";
$con = mysqli_connect($host,$user,$password,$db);
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM User WHERE username = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $name, $age, $mail, $username, $password,$image);
$user = array();
while(mysqli_stmt_fetch($statement)){
$user[name] = $name;
$user[age] = $age;
$user[mail] = $mail;
$user[username] = $username;
$user[password] = $password;
$user[image] = $image;
}
echo json_encode($user);
mysqli_close($con);
?>
当然,必须有一种最简单的方法。
谢谢!
答案 0 :(得分:1)
这是从JSONString中检索信息的方法
res