首页 > 开发 > PHP > 正文

PHP技巧:Smarty+adodb分页示例

2024-05-04 23:05:23
字体:
来源:转载
供稿:网友

利用smarty+adodb分页示例, 下面给出的是分页部份的代码。

分页文件:page.lbi

以下为引用的内容:

<table width="100%" border="0" cellpadding="0" cellspacing="0" >
  <form name="jump" method="post" action="">
    <tr>
     <td height="28" align="center" valign="bottom">当前页 <!--{$navi_cm.page}-->/<!--{$navi_cm.pages}-->
       <!--{if $navi_cm.pages gt 1 && $navi_cm.page ne 1}-->
       <a href="?<!--{$navi_cm.param}-->&page=1">[ 首页 ]</a>
       <!--{else}-->
       [ 首页 ]
       <!--{/if}-->
       <!--{if $navi_cm.pages gt 1 && $navi_cm.page ne 1}-->
       <a href="?<!--{$navi_cm.param}-->&page=<!--{$navi_cm.page-1}-->">[ 上一页 ]</a>
       <!--{else}-->
       [ 上一页 ]
       <!--{/if}-->
       <!--{if $navi_cm.pages gt 1 && $navi_cm.page ne $navi_cm.pages}-->
       <a href="?<!--{$navi_cm.param}-->&page=<!--{$navi_cm.page+1}-->">[ 下一页 ]</a> 
       <!--{else}-->
       [ 下一页 ]
       <!--{/if}-->
       <!--{if $navi_cm.pages gt 1 && $navi_cm.page ne $navi_cm.pages}-->
       <a href="?<!--{$navi_cm.param}-->&page=<!--{$navi_cm.pages}-->">[ 末页 ]</a>   
       <!--{else}-->
       [ 末页 ]
       <!--{/if}-->
       转到 字串6
       <select name="changepage" onchange="re_jump('<!--{$navi_cm.param}-->')">
    <!--{html_options options=$navi_cm.option selected=$navi_cm.page}-->
       </select>
    </td>
    </tr>
    </form>
</table>

php部份....

以下为引用的内容:

    // level e member's product commend list
    public function product_comm($size = 5){  
    $pre  = $size <> 5 && !empty($_request['lb'])  ? " and prolb like '%".$_request['lb']."%' " : "";
       $this->where = " judge_flag = 0 and pubname = '".$_request['user']."' $pre ";
       $sql = " select id, pingpai, img, huohao from user_proinfo  where ".$this->where.
        " order by pubtime desc ";
    $res = $this->selectrs->selectlimit($sql, $size, ($this->page - 1) * $size );
    $this->navipage_cm("`user_proinfo`", $size, $this->where);
    return $res;  
    }
   // embed in all must be used cat page function
   private function navipage_cm($table, $size, $where){
      $count = $this->selectrs->getone("select count(*) from $table where $where ");
   $pages = @ceil($count/$size);
      for ($i = 0; $i <= $pages; $i++) $arr[] = $i;
      $navi_cm = array(   "option"     =>  $arr,
                     "page"      =>  $this->page,
                     "pages"     =>  $pages,
                     "count"     =>  $count, 字串7
                     "size"      =>  $size,
                     "param"     =>  $this->param
                    );
      $this->tpl->assign("navi_cm", $navi_cm);
   }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表