最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 分页函数
时间:2010-08-13 编辑:简简单单 来源:一聚教程网
代码如下 | 复制代码 |
class ajaxpage{ var $result; var $anchors; var $total; var $db; var $网页特效p/jsp.html target=_blank >jsp教程agination; function __construct($qry,$starting,$recpage,$jspagination) { $this->db = &$globals['db']; $this->jspagination = $jspagination; $rst = $this->db->query($qry); $numrows = $this->db->num_rows; $qry .= " limit $starting, $recpage"; $this->result = $this->db->get_results($qry,array_a); $next = $starting+$recpage;//the number next time end //$var = ((intval($numrows/$recpage))-1)*$recpage; $page_showing = intval($starting/$recpage)+1;//the str shows on the page bar $total_page = ceil($numrows/$recpage); //total page if($numrows % $recpage != 0){ $last = ((intval($numrows/$recpage)))*$recpage; }else{ $last = ((intval($numrows/$recpage))-1)*$recpage; } $previous = $starting-$recpage; $anc = "
if($previous < 0){ $anc .= " $anc .= " }else{ $anc .= " $anc .= " } ################if you dont want the numbers just comment this block############### $norepeat = 3;//no of pages showing in the left and right side of the current page in the anchors $j = 1; $anch = ""; for($i=$page_showing; $i>1; $i--){ $fpreviouspage = $i-1; $page = ceil($fpreviouspage*$recpage)-$recpage; $anch = " if($j == $norepeat) break; $j++; } $anc .= $anch; $anc .= " $j = 1; for($i=$page_showing; $i<$total_page; $i++){ $fnextpage = $i+1; $page = ceil($fnextpage*$recpage)-$recpage; $anc .= " if($j==$norepeat) break; $j++; } ############################################################ if($next >= $numrows){ $anc .= " $anc .= " }else{ $anc .= " $anc .= " } $anc .= " $this->anchors = $anc; $this->totalstr = "page : $page_showing of $total_page . total records found: $numrows"; } } |
-
上一个: php ajax返回 json数据实例
-
下一个: php网页数字计数器代码
相关文章
- php入门级别的分页函数 07-28
- php 分页函数 07-05
- PHP 长文章分页函数 10-22
- 两个PHP通用分页函数 03-13
- php 分页函数 02-27
- PHP导出数据超时的优化建议解读 10-31