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

php 读取mysql后,json

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:42:29
Original
923 people have browsed it

代码如下: $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"}]

 

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template