Home >Backend Development >PHP Tutorial >Perfect page turning function using air jump_PHP tutorial

Perfect page turning function using air jump_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:24:31779browse

It can be said that this is the most complete page turning function you have ever seen. The detailed content is explained in the code!

//Set the number of items in the list
$ListNum =25;

//Set the starting position
if($Start_Num==" "){
$Start_Num = 0;
}

//Set forward flip
$Begin_Num=$Start_Num-$ListNum;
//Set backward flip
$ End_Num=$Start_Num+$ListNum;


//Variable for calculating the number of items when turning pages
$n=0;

//Initial value of the generated list
$artList = "";

//Connect to the database (this example uses ODBC)!
$Conn = ODBC_CONNECT ("DSN", "user", "password");
$Sql = "SELECT field FROM table";
//Haha, it is inefficient to select everything here. What an exaggeration, but this is just to demonstrate our core content - turning pages!

$Result = $ODBC_DO($Conn, $sql);

while($odbc_fetch_row($Result)){
if( $n=$Start_Num){
$thevalue = ODBC_RESULT($Result,"field");
$artList.= $n.$thevalue."
";
}
$n++;
}

//Get the starting item of the last page
if($n % $ListNum == 0){
$lastPage = $n - $ListNum;
}else{
$lastPage = $n - $n % $ListNum;
}
//Always have the previous page
$artList.= "
|



//Only if Start_Num is greater than 0, can there be a previous page
if($Start_Num > 0){
$artList.= "}else{
$artList.= "}

//If Start_Num is already within the range of the last page, there cannot be a next page
if($Start_Num $artList.= "Next page>> ";
}else{
$artList.= "Next page> ;> ";
}

//Always have the last page
$artList.= "Last page>|
";

echo $artList;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532137.htmlTechArticleIt can be said that this is the most complete page turning function you have ever seen. The detailed content is explained in the code! //Set the number of items in the list $ListNum =25; //Set the starting position if($Start_Num==""){ $Start_...
Statement:
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