一:前台加载出前端页面:HTML:lay-data="{width:800,height:400, url:data.php, page:true, id:test}js:layui.use("table",function(){var t...
lay-data="{width:800,height:400, url:'data.php', page:true, id:'test'}
layui.use("table",function(){
var table=layui.table
})
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');//防止数据库乱码必须要加
$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 "]}";
}
{"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}]}
