php 分页函数
php 分页函数
php教程 分页函数
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 = "<ul id='pagination-flickr'>";
if($previous < 0){
$anc .= "<li class='previous-off'>first</li>";
$anc .= "<li class='previous-off'>previous</li>";
}else{
$anc .= "<li class='next'><a href='网页特效:$this->jspagination(0);'>first </a></li>";
$anc .= "<li class='next'><a href='javascript:$this->jspagination($previous);'>previous </a></li>";
}
################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 = "<li><a href='javascript:$this->jspagination($page);'>$fpreviouspage </a></li>".$anch;
if($j == $norepeat) break;
$j++;
}
$anc .= $anch;
$anc .= "<li class='active'>".$page_showing."</li>";
$j = 1;
for($i=$page_showing; $i<$total_page; $i++){
$fnextpage = $i+1;
$page = ceil($fnextpage*$recpage)-$recpage;
$anc .= "<li><a href='javascript:$this->jspagination($page);'>$fnextpage</a></li>";
if($j==$norepeat) break;
$j++;
}
############################################################
if($next >= $numrows){
$anc .= "<li class='previous-off'>next</li>";
$anc .= "<li class='previous-off'>last</li>";
}else{
$anc .= "<li class='next'><a href='javascript:$this->jspagination($next);'>next </a></li>";
$anc .= "<li class='next'><a href='javascript:$this->jspagination($last);'>last</a></li>";
}
$anc .= "</ul>";
$this->anchors = $anc;
$this->totalstr = "page : $page_showing <i> of </i> $total_page . total records found: $numrows";
}
}
/php/25674.htmlwww.phpzy.comtrue/php/25674.htmlTechArticlephp 分页函数 php 分页函数 php教程 分页函数 class ajaxpage{ var $result; var $anchors; var $total; var $db; var $网页特效p/jsp.html target=_blank >jsp教程agination; function __construct($qry,$starting,$recpage,$jspaginati...
PHP之友评论