1.下載官方有例子的包,然後找到例子下面的Page例子。
2. 找到Page.class.php,復制到你自己的項目ThinkPHP/Lib/Think/Util下面。
3.
Php代碼
public function doPage(){
//echo $_GET["p"];
if(emptyempty($_GET["p"]))
$this->assign('p', 1);
else
$this->assign('p', $_GET["p"]);
$Nav = M("navigation");
$count = $Nav->count();
import("ORG.Util.Page");
$p = new Page($count, 10);
$page = $p->show();
$list = $Nav->order('Id ASC')->limit($p->firstRow.','.$p->listRows)->select();
$this->assign('page', $page);
$this->assign("list",$list);
}
4.
Php代碼
<div>{$page}</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th>ID</th>
<th>描述</th>
<th>路徑</th>
<th>備注</th>
<th>級別</th>
<th>父導航Id</th>
<th>編輯</th>
<th>刪除</th>
</tr>
<present name="list">
<volist name="list" id="vo" mod="2">
<eq name="mod" value="0">
<tr class='tr1'>
<td>{$vo.Id}</td>
<td>{$vo.description}</td>
<td>{$vo.addr}</td>
<td>{$vo.remarks}</td>
<td>{$vo.level}</td>
<td>{$vo.parsentId}</td>
<td><a href="__URL__/getNavigationById/id/{$vo.Id}/p/{$p}">Edit</a></td>
<td><a href="__URL__/delNavigationById/id/{$vo.Id}/p/{$p}">Delete</a></td>
</tr>
</eq>
<eq name="mod" value="1">
<tr class='tr2'>
<td>{$vo.Id}</td>
<td>{$vo.description}</td>
<td>{$vo.addr}</td>
<td>{$vo.remarks}</td>
<td>{$vo.level}</td>
<td>{$vo.parsentId}</td>
<td><a href="__URL__/getNavigationById/id/{$vo.Id}/p/{$p}">Edit</a></td>
<td><a href="__URL__/delNavigationById/id/{$vo.Id}/p/{$p}">Delete</a></td>
</tr>
</eq>
</volist>
</present >
</table>
<div>{$page}</div>
作者“pyzheng”