php数据分页跳转 php分页实现跳转( 三 )


}
/**
* 设定类中指定变量名的值php数据分页跳转,如果改变量不属于这个类php数据分页跳转,将throw一个exception
*
* @param string $var
* @param string $value
*/
function set($var,$value)
{
if(in_array($var,get_object_vars($this)))
$this-$var=$value;
else {
$this-error(__FUNCTION__,$var." does not belong to PB_Page!");
}
}
/**
* 获取显示"下一页"的代码
*
* @param string $style
* @return string
*/
function next_page($style='',$nowindex_style='')
{
if($this-nowindex$this-totalpage){
return $this-_get_link($this-_get_url($this-nowindex+1),$this-next_page,$style);
}
return 'span class="'.$nowindex_style.'"'.$this-next_page.'/span';
}
/**
* 获取显示“上一页”的代码
*
* @param string $style
* @return string
*/
function pre_page($style='',$nowindex_style='')
{
if($this-nowindex1){
return $this-_get_link($this-_get_url($this-nowindex-1),$this-pre_page,$style);
}
return 'span class="'.$nowindex_style.'"'.$this-pre_page.'/span';
}
/**
* 获取显示“首页”的代码
*
* @return string
*/
function first_page($style='',$nowindex_style='')
{
if($this-nowindex==1){
return 'span class="'.$nowindex_style.'"'.$this-first_page.'/span';
}
return $this-_get_link($this-_get_url(1),$this-first_page,$style);
}
/**
* 获取显示“尾页”的代码
*
* @return string
*/
function last_page($style='',$nowindex_style='')
{
if($this-nowindex==$this-totalpage){
return 'span class="'.$nowindex_style.'"'.$this-last_page.'/span';
}
return $this-_get_link($this-_get_url($this-totalpage),$this-last_page,$style);
}
function nowbar($style='',$nowindex_style='')
{
$plus=ceil($this-pagebarnum/2);
if($this-pagebarnum-$plus+$this-nowindex$this-totalpage)$plus=($this-pagebarnum-$this-totalpage+$this-nowindex);
$begin=$this-nowindex-$plus+1;
$begin=($begin=1)?$begin:1;
$return='';
for($i=$begin;$i$begin+$this-pagebarnum;$i++)
{
if($i=$this-totalpage){
if($i!=$this-nowindex)
$return.=$this-_get_text($this-_get_link($this-_get_url($i),$i,$style));
else
$return.=$this-_get_text('span class="'.$nowindex_style.'"'.$i.'/span');
}else{
break;
}
$return.="\n";
}
unset($begin);
return $return;
}
/**
* 获取显示跳转按钮的代码
*
* @return string
*/
function select()
{
$return='select name="PB_Page_Select" onchange="self.location.href=https://www.04ip.com/''.$this-url.'\'+this.opti*****[this.selectedIndex].value "';
for($i=1;$i=$this-totalpage;$i++)
{
if($i==$this-nowindex){
$return.='option value="'.$i.'" selected'.$i.'/option';
}else{
$return.='option value="'.$i.'"'.$i.'/option';
}
}
unset($i);
$return.='/select';
return $return;
}
/**
* 获取mysql 语句中limit需要的值
*
* @return string
*/
function offset()
{
return $this-offset;
}
/**
* 控制分页显示风格(你可以增加相应的风格)
*
* @param int $mode
* @return string
*/
function show($mode=1,$style='',$nowindex_style='')
{
switch ($mode)
{
case '1':
$this-next_page='下一页';
$this-pre_page='上一页';
$this-first_page='首页';
$this-last_page='尾页';
return $this-first_page($style,$nowindex_style)." ".$this-pre_page($style,$nowindex_style)." ".$this-next_page($style,$nowindex_style)." ".$this-last_page($style,$nowindex_style).' (当前第span style="color:#C16012; font-size:12pt;"'.$this-nowindex.'/span页 共span style="color:#C16012; font-size:12pt;"'.$this-totalpage.'/span页 span style="color:#C16012; font-size:12pt;"'.$this-total.'/span条记录)';

推荐阅读