.下载官方有例子的包,然后找到例子下面的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>