一:前台加载出前端页面:
	HTML:
					
lay-data="{width:800,height:400, url:'data.php', page:true, id:'test'}
				 | 
			
	js:
	表头加载下就行了主要讲解下对接数据库和返回对象的操作。
	二:先连接数据库
					
header("Content-type:text/html;charset=utf-8");
$zhuji='localhost';
$user='root';
$port=3306;
$pwd='';
$name="test";
$conn=mysqli_connect($zhuji,$user,$pwd,$name,$port);
if(!$conn){
die("连接失败:".mysqli_connect_error());
}
mysqli_query($conn,'set names utf8');//防止数据库乱码必须要加
				 | 
			
	分页四要素:
	1 当前页
	2 每页多少条记录//每页多少条记录要和前台对接好,取名最好为limit
	3从数据库读取出多少条记录
	4总共多少页
					
$page=isset($_GET["page"])?$_GET["page"]:1; 
$limit=10;
$count=mysqli_num_rows(mysqli_query($conn,"select * from area"));
$perpage=ceil($count/$limit);
$sql="select `id`,`Names`,`parentid`,`shortname` from area limit ".($page-1)*$limit.",".$limit;
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
echo '{"code":0,"msg":"","count":1000,"data":[';
$i=1;
while($row = mysqli_fetch_assoc($result)) {
$i++;
echo json_encode($row);
if($i<mysqli_num_rows($result)+1){
echo ",";
}
}
echo "]}";
}
				 | 
			
	总结:后台返回的json数据必须和前台接口对好,否则会报错,json数据格式为
					
{"code":0,"msg":"","count":1000,"data":[{"id":10000,"username":"user-0","sex":"女","city":"城市-0","sign":"签名-0","experience":255,"logins":24,"wealth":82830700,"classify":"作家","score":57}]}
				 | 
			
本文转载自:博客园
The End


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)