首页 > php教程 > php手册 > php 读取mysql后,json

php 读取mysql后,json

WBOY
发布: 2016-06-06 19:42:29
原创
886 人浏览过

代码如下: $result=mysql_query("select g.*,u.ID as companyID,u.company,u.address,u.phone from tblgood g join tbluser u on g.companyID=u.ID where g.code=$code"); while($row=mysql_fetch_array($result)) { $image=iconv("GBk", "UTF-8//IGNORE",

代码如下:

$result=mysql_query("select g.*,u.ID as companyID,u.company,u.address,u.phone from tblgood g join tbluser u on g.companyID=u.ID where g.code=$code");
while($row=mysql_fetch_array($result))
{
     $image=iconv("GBk", "UTF-8//IGNORE", $row['image']);
  $tmp=array('goodID'=>$row['ID'],'goodName'=>$row['name'],'goodPrice'=>$row['price'],'memo'=>$row['memo'],'image'=>$image,'companyID'=>$row['companyID'],'companyName'=>$row['company'],'companyAdd'=>$row['address'],'companyPhone'=>$row['phone']);
  array_push($arr,$tmp);
}
mysql_close($con);
return json_encode($arr);

其中$row['image']数据库中存放的是图片地址,例如http://www.baidu.com/a.jpg

返回的json 为:/反斜线全部变成了\/

[{"goodID":"1","goodName":"巧乐兹","goodPrice":"2","memo":"haochi ","image":"images\/panda.jpg","companyID":"1","companyName":"柚子小店","companyAdd":"深圳","companyPhone":"05341255"}]

 

这是怎么回事呢???有那位知道??

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板