程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> ThinkPHP分頁

ThinkPHP分頁

編輯:關於PHP編程

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”
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved