分页代码开始:if($action == 'loadpic'){//加载图片
$dirimg = '../zdpicture/chnpnpic';
$arrpic = scandir($dirimg);
$allcon =&n
分页代码开始:
if($action == "loadpic"){//加载图片
$dirimg = '../zdpicture/chnpnpic';
$arrpic = scandir($dirimg);
$allcon = (count($arrpic))-2;//所有文件总数除./和../
//$php = count(preg_grep("/\.php$/", $arr));
$fengyeznosu = $allcon;//总
$pagenumKeys = "20";//分多少
$jisunefudsy = intval($fengyeznosu/$pagenumKeys) + 1;
if($page == '' || $page == '1'){
$fenyqiswiz = $page = 0;
if($fengyeznosu > $pagenumKeys){
$xuhjeswzi = $pagenumKeys;
}else{
$xuhjeswzi = $fengyeznosu;
}
}else if($page > '1'){
$fenyqiswiz = ($page - 1) * $pagenumKeys;
if($fengyeznosu > $pagenumKeys){
$xuhjeswzi = $pagenumKeys * $page;
if($xuhjeswzi > $fengyeznosu){
$xuhjeswzi = $fengyeznosu;
}
}else{
$xuhjeswzi = $fengyeznosu;
}
}
/*for($i = $fenyqiswiz; $i < $xuhjeswzi; $i++) {
echo $i.'<br>';
}*/
//javascript:goto_page(3)
require_once("../hscxzonshu/souplypages.php");
$psize = $jisunefudsy;//能分多少页
$nums = $allcon;//总数
$supae = 1;//在页面显示多少个页数
$pgrnt = $page;//当前页数
$eig = new SubPages($psize,$nums,$pgrnt,$supae,'javascript:goto_page(',1);//输出页数
$echopic .= "<ul>"."\n";
$echopic .= reaudir($dirimg,$fenyqiswiz,$xuhjeswzi);//输出图片
$echopic .= "</ul>\n";
if($page == 0){
$page = 1;
}
$echopic .= '<div class="paegmy">'.$page.'/'.$allcon."\n";
$echopic .= $eig->returnc;
$echopic .= "到第\n";
$echopic .= '<input name="jumpto" id="jumpto" type="text" size="3" value="'.($page+1).'" />'."\n";
$echopic .= "页\n";
$echopic .= '<button onclick="goto_page_num();return false;">确定</button>'."\n";
$echopic .= "</div>\n";
$qudecpyl['echojg'] = iconv("gbk","utf-8",$echopic);
echo json_encode($qudecpyl);
exit;
}souplypages.php文件内容
<?php
class SubPages{
private $each_disNums;//每页显示的条目数
private $nums;//总条目数
private $current_page;//当前被选中的页
private $sub_pages;//每次显示的页数
private $pageNums;//总页数
private $page_array = array();//用来构造分页的数组
private $subPage_link;//每个分页的链接
private $subPage_type;//显示分页的类型
private $wjt_htm;//伪静态附加
function __construct($each_disNums,$nums,$current_page,$sub_pages,$subPage_link,$subPage_type,$weijingtai="0"){
if($weijingtai=="1"){
$this->wjt_htm=".html";
}
$this->each_disNums=intval($each_disNums);
$this->nums=intval($nums);
if(!$current_page){
$this->current_page=1;
}else{
$this->current_page=intval($current_page);
}
$this->sub_pages=intval($sub_pages);
$this->pageNums=$each_disNums;
$this->subPage_link=$subPage_link;
$this->show_SubPages($subPage_type);
}
function __destruct(){
unset($each_disNums);
unset($nums);
unset($current_page);
unset($sub_pages);
unset($pageNums);
unset($page_array);
unset($subPage_link);
unset($subPage_type);
}
function show_SubPages($subPage_type){
if($subPage_type == 1){
$this->subPageCss1();
}elseif ($subPage_type == 2){
$this->subPageCss2();
}
}
function initArray(){
for($i=0;$i<$this->sub_pages;$i++){
$this->page_array[$i]=$i;
}
return $this->page_array;
}
function construct_num_Page(){
if($this->pageNums < $this->sub_pages){
$current_array=array();
for($i=0;$i<$this->pageNums;$i++){
$current_array[$i]=$i+1;
}
}else{
$current_array=$this->initArray();
if($this->current_page <= 3){
for($i=0;$i<count($current_array);$i++){
$current_array[$i]=$i+1;
}
}elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1 ){
for($i=0;$i<count($current_array);$i++){
$current_array[$i]=($this->pageNums)-($this->sub_pages)+1+$i;
}
}else{
for($i=0;$i<count($current_array);$i++){
$current_array[$i]=$this->current_page-2+$i;
}
}
}
$current_array;
}
function subPageCss1(){
$subPageCss1Str="";
// $subPageCss1Str.="共".$this->nums."条记录,";
// $subPageCss1Str.="每页显示".$this->each_disNums."条,";
// $subPageCss1Str.="当前第".$this->current_page."页 / 共".$this->pageNums."页 ";
if($this->current_page > 1){
$firstPageUrl=$this->subPage_link."1".$this->wjt_htm;
$prewPageUrl=$this->subPage_link.($this->current_page-1).')';//$this->wjt_htm;
// $subPageCss1Str.="<a href='$firstPageUrl'>首页</a> ";
$subPageCss1Str.="<a href='$prewPageUrl'>上一页</a>\n";
}else {
// $subPageCss1Str.="首页 ";
$subPageCss1Str.="<a>上一页</a>\n";
}
if($this->current_page < $this->pageNums){
$lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm;
$nextPageUrl=$this->subPage_link.($this->current_page+1).')';//$this->wjt_htm;
$subPageCss1Str.=" <a href='$nextPageUrl'>下一页</a>\n";
// $subPageCss1Str.="<a href='$lastPageUrl'>尾页</a> ";
}else {
$subPageCss1Str.="<a>下一页</a>\n";
// $subPageCss1Str.="尾页 ";
}
$this->returnc = $subPageCss1Str;
//return true;
}
function subPageCss2(){
$subPageCss2Str="";
//$subPageCss2Str.="当前第".$this->current_page."页 / 共".$this->pageNums."页";
if($this->current_page > 1){
$firstPageUrl=$this->subPage_link."1".$this->wjt_htm;
$prewPageUrl=$this->subPage_link.($this->current_page-1).$this->wjt_htm;
$subPageCss2Str.="<a href='$firstPageUrl'>首页</a>\n";
$subPageCss2Str.="<a href='$prewPageUrl' title='转到上一页'>上一页</a>\n";
}else {
$subPageCss2Str.="";
$subPageCss2Str.="";
}
$a=$this->construct_num_Page();
for($i=0;$i<count($a);$i++){
$s=$a[$i];
if($s == $this->current_page ){
$subPageCss2Str.="<span>".$s."</span>\n";
}else{
$url=$this->subPage_link.$s.$this->wjt_htm;
$subPageCss2Str.="<a href='$url'>".$s."</a>\n";
}
}
if($this->current_page < $this->pageNums){
$lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm;
$nextPageUrl=$this->subPage_link.($this->current_page+1).$this->wjt_htm;
$subPageCss2Str.="<a href='$nextPageUrl' title='转到下一页'>下一页</a>\n";
$subPageCss2Str.="<a href='$lastPageUrl'>尾页</a>\n";
}else {
$subPageCss2Str.="";
$subPageCss2Str.="";
}
echo $subPageCss2Str;
}
}
?>评论列表
发表评论
热评文章
相关阅读