Similar to dz paging code_PHP tutorial

WBOY
Release: 2016-07-20 11:05:44
Original
820 people have browsed it

A class implemented by a page scroll bar

Usage example:


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

/**
* Class that implements the scroll bar
*
* Generates a page scroll bar for display/control based on page content and data volume.
* <br> * Class_Scroll: :_Print($_SERVER['PHP_SELF'],1234,$_GET['Page'],10,$_SERVER['QUERY_STRING'],"Page",9,true);<br> *
*
* @author Zhou Beichen 2006-7-16
* @version 2.1
*
* @todo Generate a page content scroll bar
*/
class Class_Scroll{
/**
* Output page scroll bar
*
* @param string $AScriptName The page to be scrolled
* @param integer $ATotalCount The total number of scrolling information
* @param integer $ANowPageID The current page Number
* @param integer $AInnerCount Number of information in each page
* @param string $AVar Other variables and their values ​​that need to be attached
* @param string $APageKey The variable name used to specify the page number
* @param integer $APageBundle The maximum number of pages displayed in the scroll bar
* @param boolean $IncJump Whether to display the page jump drop-down list (default: true)
* @return string The page scroll bar HTML code
*/
function _Print( $AScriptName,$ATotalCount,$ANowPageID,$AInnerCount,$AVar,$APageKey="Page",$APageBundle=9,$IncJump = true){
// No items
if( $ATotalCount == 0 or $ATotalCount == "") return "No relevant content.";//"No Item Here.";
// Calculate the total number of pages
$PageCount = ceil($ATotalCount / $AInnerCount);
// Check and control the current page number value
if($ANowPageID < 1) $ANowPageID = 1;
if($ANowPageID > $PageCount) $ANowPageID = $PageCount;
// OK of course The numerical link value to be displayed
$StartNum = ($ANowPageID - floor($APageBundle / 2)) > 0 ? ($ANowPageID - floor($APageBundle / 2)) : 1;
$EndNum = ( $PageCount - $StartNum) < $APageBundle ? $PageCount : ($StartNum + $APageBundle - 1);
if((($EndNum - $StartNum) < $APageBundle)&&($PageCount > $APageBundle )) $StartNum = $EndNum - $APageBundle + 1;
// Get variable
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]);
}
}
// Home page link
$OutStringr = sprintf('%s%s', $AScriptName,$VarString,$APageKey,"1","Home","r");
// Previous page link
$OutStringr .= ($ANowPageID==1) ? " " : sprintf ('%s%s',$AScriptName,$VarString,$APageKey,$ANowPageID-1,"Previous page" ,"r");
// Middle page link
for($i = $StartNum; $i <= $EndNum; $i++)
$OutStringr .= ($i==$ANowPageID ) ? sprintf("%s%s",$i,"r") : sprintf('%s%s',$AScriptName,$VarString,$APageKey,$i,$i,"r");
// Next page link
$OutStringr. = ($ANowPageID==$PageCount) ? " " : sprintf('%s%s',$AScriptName,$VarString ,$APageKey,$ANowPageID+1,"Next page","r");
// Last page link
$OutStringr .= sprintf('%s Total %s pages %s items %s',$AScriptName,$VarString,$APageKey,$PageCount,"last page",$PageCount,$ATotalCount,"r" );
// Jump link
if ($IncJump){
$OutStringr .= sprintf("";
}
// Output
return $OutStringr;
}
}
?> ;


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445082.htmlTechArticleA class usage example for page scroll bar implementation: ?php Class_Scroll :: _Print ( $_SERVER [ 'PHP_SELF' ] , 1234 , $_GET [ 'Page' ], 10 , $_SERVER [ 'QUERY_STRING' ], Page , 9 , true );...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template