Home > Backend Development > PHP Tutorial > Realize the processing of ten pages forward and ten pages back_PHP tutorial

Realize the processing of ten pages forward and ten pages back_PHP tutorial

WBOY
Release: 2016-07-21 16:05:47
Original
1155 people have browsed it

/*==== Display data records in pages =====
One page has ten consecutive page connections
One page can display $limit_row record information
It also has the function of turning the next ten pages and the previous ten pages
================================== ===

------You need to pass in the value $total_row;$limit_row;$pagename;-----
$total_row is the total number of rows in the selected query results
$ limit_row is the maximum number of rows displayed on each page
$pagename is the name of the returned display page. (without suffix)
----------------------------------------- ----------

--------------------------------- -------------------
$page The page currently being read
$total_page is the number of pages that can be divided into.
$row_begin is the starting number Start reading the row
$row_end is the number of rows read
-------------------------------- ---------------------*/

if (!$page){ $page=1;}
$total_page=ceil( $total_row/$limit_row);
$row_begin=$limit_row*($page-1);
if($page==$total_page&&($total_row%$limit_row)){
$read_row=( $total_row%$limit_row);
}else{$read_row=$limit_row;}
if($total_page<=10){
$page_begin=0;
$page_end=$total_page;
$page10=1;
$newpage10=1;
}else{
//--------------Paging displays the next ten pages----- -----------
// $page10 is how many ten pages there are in total
// $newpage10 is the starting position of reading ten pages
// $page_endx is reading The last number of pages

$page10=ceil($total_page/10);
if($newpage10 ===""){$newpage10=1;}
$page_begin=10*($ newpage10-1);
if($newpage10==1)
{
if($newpage10==($page10-1)&&($total_page%10))
{
$page_endx=$total_page%10; =11">Next $page_endx page |";
}else{
$page_end=10;
echo "Next ten pages |";
}
}elseif($newpage10>1){
if($newpage10==$page10&&($total_page%10))
{$page_end=$total_page%10;
echo "| Previous Ten pages |The last $page_end page|";
}else{
if($newpage10==($page10-1)&&($total_page%10) )
{ $page_endx=$total_page%10;
$page_end=10;
echo "| First ten pages | Next $page_endx page |";
} else{
$page_end=10;
echo "| First ten pages | Next ten pages |";
}
}

}
}

//----------------------Page number every ten pages------------- --------------------------
echo "Total: ".$total_row." Article ";
for ($n= $page_begin+1;$n<=$page_begin+$page_end;$n++){
echo "$n ";
}
echo "page";

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315554.htmlTechArticle? /*====Display data records in pages====== One page has consecutive The connection of ten pages can display $limit_row record information on one page and has the function of turning the next ten pages and the previous ten pages====...
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