PHP技巧:Smarty+adodb分页示例

时间:2021-04-16

  PHP技巧实例:Smarty+adodb分页示例

  利用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);
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章