PHP ajax 分页类代码

2019-04-10 14:34:26丽君

$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="location.replace(this.value)" >';
for($i=1;$i<=$this->totalpage;$i++)
{
if($i==$this->nowindex){
$return.='<option value='.$this->_get_url($i).' selected>'.$i.'</option>';
}else{
$return.='<option value='.$this->_get_url($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,$url='')
{
switch ($mode)
{
case '1':
$this->next_page='下一页';
$this->pre_page='上一页';
return $this->pre_page().$this->nowbar().$this->next_page().'第'.$this->select().'页';
break;
case '2':
$this->next_page='下一页';
$this->pre_page='上一页';
$this->first_page='首页';
$this->last_page='尾页';
return $this->first_page().$this->pre_page().'[第'.$this->nowindex.'页]'.$this->next_page().$this->last_page().'第'.$this->select().'页';
break;
case '3':
$this->next_page='下一页';
$this->pre_page='上一页';
$this->first_page='首页';
$this->last_page='尾页';
return $this->first_page().$this->pre_page().$this->next_page().$this->last_page();
break;
case '4':
$this->next_page='next';
$this->pre_page='last';
return $this->pre_page().$this->nowbar().$this->next_page();
break;
case '5':
return $this->pre_bar().$this->pre_page().$this->nowbar().$this->next_page().$this->next_bar();
break;
case '6':
//启用了“上一页”,“下一页”,“最后一页”。可根据情况启用“第一页”。
//$this->first_page='<img src="'.HOSTPATH.'images/propageup.jpg" width="64" height="13" >';
$this->pre_page='<img src="'.HOSTPATH.'images/propageup.jpg" style="width:58px; height:18px;">';
$this->next_page='<img src="'.HOSTPATH.'images/propagedown.jpg" style="width:58px; height:18px;">';
$this->last_page='最后一页';
//return "<td width=39 align='center'>".$this->select()."</td>"."<td><span style='color:#666666'>页</span></td>"."<td width=72 align=right>".$this->first_page()."</td>"."<td width=72 align=right>".$this->pre_page()."</td>"."<td width=72 align=right>".$this->next_page()."</td>"."<td width=72 align=right>".$this->last_page()."</td>";
相关文章 大家在看