A high-ai paging function and a url function_PHP tutorial

WBOY
Release: 2016-07-21 16:04:43
Original
687 people have browsed it

This paging function is very powerful
Just take a look and you will know
function ppage($total, $page, $e_page = 15, $e_block = 10, $url = '', $color = '') {
if(!strpos($url,'?'))
$url.='?';
else
$url.='&';
if($color< ;>'') {
$color ='';
$colore = '
';
}
$totalpage = ceil($total/$e_page); //Number of pages
$p_block = ceil($totalpage/$e_block); //Number of blocks
$n_block = ceil($page/$e_block); //Now block
$start = ($n_block-1)*$e_block+1;
$ended = $n_block*$e_block;
if($ended>$total)
$ended = $totalpage;
if($n_block>1) {
$link = $start-1;
$head =''.$color.'[<=]'.$colore.' ';
}
if($n_block<$p_block) {
$link = $ended+1;
$foot = ''.$color.'[=>]'.$colore.' ';
}
for($i=$start;$i<=$ended;$i++) {
$middle .=''.$color.'['.$i.']'.$colore.' ';
}
return $head. $middle.$foot;
}
The following is the method to get the current url
function geturl() {
$headers = getallheaders();
$url = 'http://' .$headers['Host'].$SCRIPT_NAME;
return $url;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315917.htmlTechArticleThis paging function is very advanced and can only be understood by looking at function ppage($total, $page, $e_page = 15, $e_block = 10, $url = '', $color = '') { if(!strpos($url,'?')) $url.='?'; else $u...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!