栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

无法从MySQL表检索与特定“ uid”匹配的数据

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

无法从MySQL表检索与特定“ uid”匹配的数据

在您的Android应用中,您需要一个JSONArray:

// store incoming stream in an arrayJSonArray jArray = new JSonArray(streamToString(instream));

但是,在您的PHP文件中,您仅输出多个单独的JSON对象,而不是实际数组。我认为,您应该首先从数据库中的PHP数组中收集所有项目,然后再对其进行编码和输出一次。

我的PHP技能有点生锈,但是我希望这能起作用:

//store # of rows returned$num_rows = mysql_num_rows($query);if ($num_rows >= 1) {    $output = array();    while($results = mysql_fetch_assoc($query)) {        // append row to output        $output[] = results    }    mysql_close();  // shouldn't that be outside the if block?    //enpre the returned data in JSON format    echo json_enpre($output);}

我希望输出是这样的(也许没有缩进):

[    {"nid":"1","vid":"1","type":"goal","language":"","title":"test","uid":"1","status":"1","created":"1342894493","changed":"1342894493","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"},    {"nid":"2","vid":"2","type":"goal","language":"","title":"test2","uid":"1","status":"1","created":"1342894529","changed":"1342894529","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"},    {"nid":"5","vid":"5","type":"goal","language":"","title":"run","uid":"1","status":"1","created":"1343506987","changed":"1343506987","comment":"2","promote":"1","moderate":"0","sticky":"1","tnid":"0","translate":"0"},    {"nid":"9","vid":"9","type":"goal","language":"","title":"run to the hills","uid":"1","status":"1","created":"1343604338","changed":"1343605100","comment":"2","promote":"0","moderate":"0","sticky":"0","tnid":"0","translate":"0"}]


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/570203.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号