«
PHP Smarty+adodb分页示例

时间:2008-5-31    作者:Deri    分类: 分享


   <p>  利用Smarty+adodb分页示例, 下面给出的是分页部份的代码。有不懂可以在下面留言,站长会看到并回复的。</p><p>  分页文件:page.lbi</p><code><table width="100%" border="0" cellpadding="0" cellspacing="0" ><br /> <form name="jump" method="post" action=""><br />  <tr><br />   <td height="28" align="center" valign="bottom">当前页 <!--{$navi_cM.page}-->/<!--{$navi_cM.pages}--><br />    <!--{if $navi_cM.pages gt 1 && $navi_cM.page ne 1}--><br />    <a href="?<!--{$navi_cM.param}-->&page=1">[ 首页 ]</a><br />    <!--{else}--><br />    [ 首页 ]<br />    <!--{/if}--><br />    <!--{if $navi_cM.pages gt 1 && $navi_cM.page ne 1}--><br />    <a href="?<!--{$navi_cM.param}-->&page=<!--{$navi_cM.page-1}-->">[ 上一页 ]</a><br />    <!--{else}--><br />    [ 上一页 ]<br />    <!--{/if}--><br />    <!--{if $navi_cM.pages gt 1 && $navi_cM.page ne $navi_cM.pages}--><br />    <a href="?<!--{$navi_cM.param}-->&page=<!--{$navi_cM.page+1}-->">[ 下一页 ]</a> <br />    <!--{else}--><br />    [ 下一页 ]<br />    <!--{/if}--><br />    <!--{if $navi_cM.pages gt 1 && $navi_cM.page ne $navi_cM.pages}--><br />    <a href="?<!--{$navi_cM.param}-->&page=<!--{$navi_cM.pages}-->">[ 末页 ]</a>  <br />    <!--{else}--><br />    [ 末页 ]<br />    <!--{/if}--><br />    转到 字串6<br />    <select name="changepage" onchange="re_jump('<!--{$navi_cM.param}-->')"><br />  <!--{html_options options=$navi_cM.option selected=$navi_cM.page}--><br />    </select><br />  </td><br />  </tr><br />  </form><br /></table></code><p>  php部份....</p><code>  // level E member's product commend list<br />  public function product_comm($size = 5){ <br />  $pre = $size <> 5 && !empty($_REQUEST['lb']) ? " AND prolb LIKE '%".$_REQUEST['lb']."%' " : "";<br />    $this->where = " judge_flag = 0 AND pubname = '".$_REQUEST['user']."' $pre ";<br />    $sql = " SELECT id, pingpai, img, huohao FROM user_proinfo WHERE ".$this->where.<br />    " ORDER BY pubtime DESC ";<br />  $res = $this->selectRs->SelectLimit($sql, $size, ($this->page - 1) * $size );<br />  $this->NaviPage_cM("`user_proinfo`", $size, $this->where);<br />  return $res; <br />  }<br />  // embed in all must be used cat page function<br />  private function NaviPage_cM($table, $size, $where){<br />   $count = $this->selectRs->GetOne("SELECT COUNT(*) FROM $table WHERE $where ");<br />  $pages = @ceil($count/$size);<br />   for ($i = 0; $i <= $pages; $i++) $arr[] = $i;<br />   $navi_cM = array(  "option"   => $arr,<br />           "page"   => $this->page,<br />           "pages"   => $pages,<br />           "count"   => $count, 字串7<br />           "size"   => $size,<br />           "param"   => $this->param<br />          );<br />   $this->tpl->assign("navi_cM", $navi_cM);<br />  }</code></p>