-
-
小安Andrew
2016-10-18
- 组装成接口数据
-
截图
0赞 · 0采集
-
-
勇敢的心_myheart
2016-10-08
- 返回函数
-
截图
0赞 · 1采集
-
-
勇敢的心_myheart
2016-10-08
- 编写接口
-
截图
0赞 · 0采集
-
-
慕粉13147073294
2016-09-07
- rewrite路径
-
截图
0赞 · 0采集
-
-
慕粉13147073294
2016-09-07
- rewrite路径
-
截图
0赞 · 0采集
-
-
沙澧情缘
2016-08-27
- 1、连接数据库、获取数据
2、把获取到的数据组装成接口数据以提供通信
$conn = mysql_connect("localhost","root","root","数据库名");
$sql="select * from table1 as a join table2 as b on a.字段=b.字段 order by a.count desc limit 5";
$res = mysql_query($sql,$conn);
while($row = mysql_fetch_assoc()){
$res[] = $row;
}
function shop($code = 0, $message = 'error',$data = array()){
$res = array(
'code' => $code,
'message' => $message,
'data' => $data,
)
}
echo json_encode($res);
-
0赞 · 0采集
-
-
RRadix
2016-06-06
- json_encode(数组)
-
截图
0赞 · 0采集
-
-
一二三123
2016-05-27
- show为通信接口的方法
-
截图
0赞 · 0采集
-
-
RenneXV
2016-03-15
- 查询数据库,返回ajax
-
截图
0赞 · 0采集
-
-
小贵子丶
2016-03-07
- 编写ajax接口,很重要
-
截图
0赞 · 1采集
-
-
phpcreate
2016-03-06
- 1.获取数据,转换为json
2.编写ajax
//return是返回值,并不输出到浏览器,要它输出的话要echo
-
0赞 · 0采集
-
-
流枫将落
2016-02-02
- 1、获取数据
2、把获取到的数据组装成接口数据通信(echo json_encode($result);)
-----
*注意判断SQL是否成功
补1(图下半部分):
function show($code=0,$message='error',$data=array()){
$resutlt=array(
'code'=$code,
'message'=$message,
'data'=$data
);
echo json_encode(result);
}
-
截图
0赞 · 1采集
-
-
林静听蝉
2015-11-08
- hot.php(排行榜)<br>
<?php<br>
//排行榜接口数据<br>
//1、获取数据 2、把我们获取到的数据组装成接口数据提供通信<br>
<br>
require_once('../db.php');<br>
<br>
$connect = Db::getInstance()->connect();<br>
<br>
//联表查询<br>
$sql = "select * from hit as a join news as b on a.news_id = b.id order by a.count desc limit 3";<br>
<br>
$result = mysql_query($sql,$connect);<br>
<br>
while($row = mysql_fetch_assoc($result)){<br>
$res[] = $row;<br>
}<br>
//print_r($res);<br>
<br>
return show(1,'success',$res);<br>
<br>
function show($code = 0,$message = 'error',$data = array()){<br>
$result = array(<br>
'code' => $code,<br>
'message' => $message,<br>
'data' => $data,<br>
);<br>
echo json_encode($result);<br>
}
json浏览扩展是谷歌chrome浏览器的JSON-handle
-
截图
0赞 · 0采集
-
-
枫影xu
2015-10-19
- 1、获取数据
2、把获取到的数据组装成接口数据通信(按json的方式来输出)
echo json_encode($result);
-
0赞 · 0采集
-
-
恋高三
2015-10-14
- 编写接口步骤
-
截图
0赞 · 0采集
-
-
慕瓜8049634
2015-08-18
- 局部动态化的实现1
-
截图
0赞 · 0采集
-
-
慕少8981271
2015-07-24
- select * from hit as a join
mysql_fetch_assoc 关联的数据
-
0赞 · 0采集
-
-
didiniao12315
2015-03-16
- 局部动态页面生成
-
截图
0赞 · 0采集
-
-
curlyCheng
2015-03-02
- 数据库操作
-
截图
0赞 · 0采集
-
-
Julisky
2015-02-16
- 1、获取数据
2、把获取到的数据组装成接口数据通信(按json的方式来输出)
echo json_encode($result);
-
截图
0赞 · 6采集