Home > php教程 > php手册 > body text

类似dz 分页代码

WBOY
Release: 2016-06-13 11:21:44
Original
1030 people have browsed it

一个页面滚动栏实现的类

用法示例:


Class_Scroll::_Print($_SERVER['PHP_SELF'],1234,$_GET['Page'],10,$_SERVER['QUERY_STRING'],"Page",9,true);
?>

/**
 * 实现滚动栏的类
 *
 * 根据页面内容,数据量,生成一个用来显示/控制的页面滚动栏.
 * <br> * Class_Scroll::_Print($_SERVER['PHP_SELF'],1234,$_GET['Page'],10,$_SERVER['QUERY_STRING'],"Page",9,true);<br> *
 *
 * @author 周贝晨 2006-7-16
 * @version 2.1
 *
 * @todo 生成一个页面内容滚动栏
 */
class Class_Scroll{
 /**
  * 输出页面滚动栏
  *
  * @param string $AScriptName 要进行滚动的页面
  * @param integer $ATotalCount 滚动信息的总数
  * @param integer $ANowPageID 当前页号
  * @param integer $AInnerCount 每页内的信息数
  * @param string $AVar 需要附带的其它变量及其值
  * @param string $APageKey 用来指定页号的变量名
  * @param integer $APageBundle 滚动栏显示的页数批示最大值
  * @param boolean $IncJump 是否显示页面跳转下拉单(默认:true)
  * @return string 页面滚动栏的HTML代码
  */
 function _Print($AScriptName,$ATotalCount,$ANowPageID,$AInnerCount,$AVar,$APageKey="Page",$APageBundle=9,$IncJump = true){
  // 没有项目
  if( $ATotalCount == 0 or $ATotalCount == "") return "没有相关内容.";//"No Item Here.";
  // 计算总页数
  $PageCount = ceil($ATotalCount / $AInnerCount);
  // 检查控制当前页码值
  if($ANowPageID   if($ANowPageID > $PageCount) $ANowPageID = $PageCount;
  // 确定当然要显示的数码链接值
  $StartNum = ($ANowPageID - floor($APageBundle / 2)) > 0 ? ($ANowPageID - floor($APageBundle / 2)) : 1;
  $EndNum = ($PageCount - $StartNum)   if((($EndNum - $StartNum) $APageBundle)) $StartNum = $EndNum - $APageBundle + 1;
  // 获得变量
  if(strlen($AVar) > 0) $Vars = explode("&",$AVar);
  if(count($Vars) > 0){
   for($i=0;$i    $v = explode("=",$Vars[$i]);
    if($v[0]!=$APageKey) $VarString.=sprintf("%s=%s&",$v[0],$v[1]);
   }
  }
  // 首页链接
  $OutStringr = sprintf('%s%s',$AScriptName,$VarString,$APageKey,"1","首页","r");
  // 上一页链接
  $OutStringr .= ($ANowPageID==1) ? " " : sprintf('%s%s',$AScriptName,$VarString,$APageKey,$ANowPageID-1,"上一页","r");
  // 中间页链接
  for($i = $StartNum; $i   $OutStringr .= ($i==$ANowPageID) ? sprintf("%s%s",$i,"r") : sprintf('%s%s',$AScriptName,$VarString,$APageKey,$i,$i,"r");
  // 下一页链接
  $OutStringr .= ($ANowPageID==$PageCount) ? " " : sprintf('%s%s',$AScriptName,$VarString,$APageKey,$ANowPageID+1,"下一页","r");
  // 尾页链接
  $OutStringr .= sprintf('%s 共%s页%s条%s',$AScriptName,$VarString,$APageKey,$PageCount,"尾页",$PageCount,$ATotalCount,"r");
  // 跳转链接
  if ($IncJump){
   $OutStringr .= sprintf("";
  }
  // 输出
  return $OutStringr;
 }
}
?>

 


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template