protected function do_page1($table){
$m=M($table);
import('ORG.UTIL.Page');
$where['id']=$_REQUEST['id'];//在表單中傳入數據的主鍵ID,否則取0
$arr=$m->where($where)->find();
$cut='<hr style="page-break-after:always;" class="ke-pagebreak" />';
$arr['content']=array_filter(explode($cut,$arr['content']));
$count=count($arr['content']);
//dump($arr);
//dump($count);
$page=new Page($count,1);
$page->setConfig('theme', "%totalRow% %header% %nowPage%/%totalPage% 頁 %upPage% %first% %prePage% %linkPage% %downPage%%nextPage% %end%"
);
$show=$page->show();
$p = I('get.p',1,'intval');
$firstRow = ($p === 1) ? 0 : ($p - 1) * 1;
$arr['content']=array_slice($arr['content'],$firstRow,1);
$this->assign('arr',$arr);
//dump ($arr);
$this->assign('page',$show);// 賦值分頁輸
$this->display();
}
thinkphp 文章分頁
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.