一个高ai的分页函数和一个url函数

2016-01-29 14:51 6 1 收藏

一个高ai的分页函数和一个url函数,一个高ai的分页函数和一个url函数

【 tulaoshi.com - PHP 】

  这个分页函数非常高只能的
看看就知道了
function ppage($total, $page, $e_page = 15, $e_block = 10, $url = '', $color = '') {
if(!strpos($url,'?'))
   $url.='?';
else
   $url.='&';
if($color<'') {
   $color   ='<font color='.$color.'';
   $colore  = '</font';
}
$totalpage = ceil($total/$e_page);  //页面数目
$p_block   = ceil($totalpage/$e_block);  //块数目
$n_block   = ceil($page/$e_block); //现在块
$start     = ($n_block-1)*$e_block+1;
$ended     = $n_block*$e_block;
if($ended$total)
   $ended   = $totalpage;
if($n_block1) {
   $link    = $start-1;
   $head    ='<a href='.$url.'page='.$link.''.$color.'[<=]'.$colore.'</a&nbsp;';
}
if($n_block<$p_block) {
   $link    = $ended+1;
   $foot    = '<a href='.$url.'page='.$link.''.$color.'[=]'.$colore.'</a';
}
for($i=$start;$i<=$ended;$i++) {
   $middle .='<a href='.$url.'page='.$i.''.$color.'['.$i.']'.$colore.'</a&nbsp;';
}
return $head.$middle.$foot;
}
下面是取得当前url的方法
function geturl() {
$headers = getallheaders();
$url     = 'http://'.$headers['Host'].$SCRIPT_NAME;
return $url;
}  

来源:http://www.tulaoshi.com/n/20160129/1494481.html

延伸阅读
标签: Web开发
select id="Year" name="Year"option value=""/option/select年 select id="Month" name="Month"/select月 select id="Day" name="Day"/select日br / select id="iYear" name="iYear"option value=""/option/select年 select id="iMonth" name="iMonth"/select月select id...
标签: PHP
  -------------------------------论坛-------------------------- 数据表 create table guest(id int not null auto_increment,primary key(id),title varchar(50),email varchar(30),homepage varchar(30),name varchar(30),text text,relay int,r_time date) create table relay(id int not null auto_increment,primary &nb...
标签: Web开发
很多语言都有类似php中的include和require功能的函数,而唯独javascript没有。  很早就想在js中实现类似的功能,尝试了很多次都没有成功,那天在google上搜索一些关于动态加载css文件的关键词时,发现一个blog(地址找不到了)上的一个为网页的head标签增加link元素的函数,于是就改了一下,写了这个函数。  用法:  include...
标签: Web开发
/** 作者:慈勤强 Email: cqq1978@Gmail.com */ 函数很简单, 主要是针对字符串和数字两种类型的传入数据分别进行了处理,具体用法: 字符类型的 strUsername = CheckInput(Request(“username“),“s“) 数字类型的 ID = CheckInput(Request(“id“),“i“) 下面是函数 Function CheckInput...
标签: ASP
  /** 作者:慈勤强 Email: cqq1978@Gmail.com */ 函数很简单, 主要是针对字符串和数字两种类型的传入数据分别进行了处理,具体用法: 字符类型的 strUsername = CheckInput(Request(“username“),“s“) 数字类型的 ID = CheckInput(Request(“id“),“i“) 下面是函数 Function CheckInput(str,strType)    '函数功能...

经验教程

727

收藏

61
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部

如果您有什么好的建议或者疑问,可以联系我们。 商务合作QQ:3272218541;3282258740。商务合作微信:13319608704;13319603564。

加好友请备注机构名称。让我们一起学习、一起进步tulaoshi.com 版权所有 © 2019 All Rights Reserved. 湘ICP备19009391号-3

微信公众号