首页 > 解决方案 > 当查询始终不同时,如何使用json从mysql中获取android中的数据,

问题描述

假设我必须根据那里的 id 向不同的用户显示不同的数据,所以我需要将 id 传递给 php 脚本,但 json 是一个固定的查询过程(我认为)现在我能做什么???

标签: phpandroidmysqljson

解决方案


像这样为不同的用户使用 id :

$.post( "ajax.php?user_id=1", function( data ) { 
     //
},"Json");

并在后端处理这个请求,例如(不要忘记清理 $_GET['user_id'],这只是一个简单的例子)

$query = "Select * from users where users.id = $_GET['user_id'] ";
// your code and $result .....
echo json_encode($result);

推荐阅读