標籤:style io ar sp div on cti html ad
1.我剛學的時候都不知道thinkphp的分頁是這麼回事,不過現在好多啦!
1.thinkphp的分頁首先要導包:
這是action :
class TestAction extends Action{
public function index(){
import("@.ORG.Page"); //匯入分頁的包。
$count = M(‘orders140619‘,‘ebay_‘,‘DB_ORDER‘)->count(); //得到總數。
$page = new Page($count,10);
$page->rollPage = 7; //分頁顯示的頁數 首頁 « 上一頁 1234567 下一頁 » 末頁 1/16 頁
$page->setConfig(‘theme‘,‘%totalRow% %header% %first% %upPage% %linkPage% %downPage% %end% %nowPage%/%totalPage% 頁‘);
$show = $page->show(); //顯示
$limit = $page->firstRow. ‘,‘ .$page->listRows; //設定顯示的行數。
$list = M(‘orders140619‘,‘ebay_‘,‘DB_ORDER‘)->limit($limit)->field(‘id,order_number_id,account_id‘)->select();//查詢所需要的值
$this->assign(‘list‘,$list);
$this->assign(‘page‘,$show);// 賦值分頁輸出
$this->display();
}
}
頁面的顯示:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>分頁頁面</title>
</head>
<body>
<table border="1px" align="center">
<tr><td>訂單號</td><td>隨筆</td></tr>
<volist name="list" id="vo">
<tr><td>{$vo.id}</td>
<td>{$vo.order_number_id}</td>
<td>{$vo.account_id}</td>
</tr>
</volist>
</table>
<div style="text-align:center">{$page}</div><!--這就是顯示分頁的功能-->
</body>
</html>
thinkphp分頁