<?php require_once 'db.php'; $pageNow = 1;//当前页 $pageSize = 5;//一页多少行 $lineCount = 0;//总记录书 $pageCount = 0;//总页数 if(isset($_GET['pageNow'])){ $pageNow = $_GET['pageNow']; } $sql = "select count(*) as count from channel_package"; $res=$conn->query($sql); while($row=$res->fetch_assoc()){ $lineCount = $row['count']; } $pageCount = ceil($lineCount/$pageSize); $sql = "select * from channel_package limit ".($pageNow-1) * $pageSize.", $pageSize"; $res=$conn->query($sql); $data = array(); while($row=$res->fetch_assoc()){ array_push($data,array( "id" => $row['id'], "id_string" => $row['id_string'], )); } echo json_encode(array("data"=>$data)); ?>