Home > Backend Development > PHP Tutorial > PHP high AI paging function and url function

PHP high AI paging function and url function

WBOY
Release: 2016-08-08 09:33:54
Original
1012 people have browsed it

This paging function is very powerful
Just take a look and you’ll 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;
}
Here is how to get the current url
function geturl() {
$headers = getallheaders();
$url = 'http://'.$headers['Host'].$SCRipT_NAME;
return $url;
}

The above introduces the paging function and url function of PHP high AI, including the content of paging function. I hope it will be helpful to friends who are interested in PHP tutorials.

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