已知数组Ajax分页

<?

$stamp_result =array(0=>'xx',1=>'kk',2=>'gfyfu',3=>'oio',

4=>'ydftd',5=>'fufty',6=>'jugtyu',7=>'kjh',8=>'pop',9=>'ssaas');

//$page_count = count($a);
$page_size = 4;//一页显示数
//$page_no = $_REQUEST['page_no'];
$page_no=  intval($_REQUEST['page_no']);//取得当前页
if (!$page_no || $page_no < 0) {
 $page_no= 1;
}
//$iPagesize = isset($_REQUEST["pagesize"]) ? (int)trim($_REQUEST["pagesize"]) : 2;
//$iPageno = isset($_REQUEST["pageno"]) ? (int)trim($_REQUEST["pageno"]) : 1;


//$page_size = 16;
$total = count($stamp_result);//总记录数
$max_page = ceil($total/$page_size);//需要显示几页
$page_no = min($max_page,$page_no);//当前页
$start = ($page_no-1)*$page_size;

//要判断最后一页剩几个  然后循环几次
$residue = ($page_no >= $max_page) ? $total%$page_size : 0;
$page_size = ($residue >0) ? $residue : $page_size;
 

//默认page_no为1,显示第一页的数据
if ($total > 0) {
 for ($k=0; $k<
$max_page; $k++){
  $start_id = $k+$start;
   echo $start_id+1;
 }

你可能感兴趣的:(Ajax)