php将从数据库中取得的数据转换成json格式并输出的方法
发布时间:2023-09-21 10:09:05 所属栏目:PHP教程 来源:
导读:将查询到的数组存放到一个新的数组中,然后返回json格式,如下所示:
header('content-type:application/json;charset=utf8');
$results = array();
while ($row = mysql_fetch_assoc($resul
header('content-type:application/json;charset=utf8');
$results = array();
while ($row = mysql_fetch_assoc($resul
将查询到的数组存放到一个新的数组中,然后返回json格式,如下所示: header('content-type:application/json;charset=utf8'); $results = array(); while ($row = mysql_fetch_assoc($result_query)) { $results[] = $row; } if($results){ echo json_encode($results); }else{ echo mysql_error(); } (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐