求PHP分页代码。 修改成 首页 上一页 共**条记录 下一页 末页 *****后面是分页显示10页 20
http://hi.baidu.com/zuzuhuaihuai/blog/item/f0c350a33bfe90e59152eee5.html?timeStamp=12...
http://hi.baidu.com/zuzuhuaihuai/blog/item/f0c350a33bfe90e59152eee5.html?timeStamp=1294411405361 这里我发了原先的分页代码。
展开
1个回答
展开全部
呵呵,我把我的分页类给你吧!
<?php
//分页类
class pagelist
{
public $pagesize=5; //默认的每页记录条数
public $fisrtpage=1; //首页
public $endpage,$total,$privious,$next;//尾页、总页数、上一页、下一页
public $page,$curentrecord,$url; //当前页数和当前开始记录
//设置页面记录个数
function setpagesize($num)
{
$this->pagesize=$num;
}
//获得当前文件在根目录下的相对路径和添加部分字符
function geturl($add="?")
{
$this->url=$_SERVER['PHP_SELF'].$add;
return $this->url;
}
//获得某个表的所有记录数
function gettotal($tablename)
{
$totalsql="SELECT * FROM $tablename";
$result=mysql_query($totalsql);
$this->total=mysql_num_rows($result);
return $this->total;
}
//获得最后一页页数
function getendpage()
{
$this->endpage=ceil($this->total/$this->pagesize);
return $this->endpage;
}
//获得$page
function getpage($page)
{
$this->page=$page?$page:1;
return $this->page;
}
//获得当前记录
function getcurentrecord()
{
$this->curentrecord=($this->page-1)*$this->pagesize;
return $this->curentrecord;
}
//上一页、下一页方式
function listpage()
{
if ($this->page<=$this->fisrtpage)//首页
{
echo "首页 ";
}else {
echo "<A href='$this->url ?page=$this->fisrtpage'>首页</A> ";
}
if ($this->page>$this->fisrtpage) {//上一页
$privious=$this->page-1;
echo "<A href='$this->url page=$privious'>上一页</A> ";
}
if ($this->page<=$this->endpage)//下一页
{
$next=$this->page+1;
echo "<A href='$this->url page=$next'>下一页</A> ";
}
if ($this->page<$this->endpage) {//尾页
echo "<A href='$this->url page=$this->endpage'>尾页</A> ";
}else {
echo "尾页";
}
}
//分页循环方式,数字显示
//分页循环方式,数字显示
function listcycle()
{
for ($i=1;$i<=$this->endpage;$i++)
{
if ($this->page==$i)
{
echo $i." ";
}else
{
echo "<A href='$this->url page=$i'>$i</A> ";
}
}
}
}
?>
<?php
//分页类
class pagelist
{
public $pagesize=5; //默认的每页记录条数
public $fisrtpage=1; //首页
public $endpage,$total,$privious,$next;//尾页、总页数、上一页、下一页
public $page,$curentrecord,$url; //当前页数和当前开始记录
//设置页面记录个数
function setpagesize($num)
{
$this->pagesize=$num;
}
//获得当前文件在根目录下的相对路径和添加部分字符
function geturl($add="?")
{
$this->url=$_SERVER['PHP_SELF'].$add;
return $this->url;
}
//获得某个表的所有记录数
function gettotal($tablename)
{
$totalsql="SELECT * FROM $tablename";
$result=mysql_query($totalsql);
$this->total=mysql_num_rows($result);
return $this->total;
}
//获得最后一页页数
function getendpage()
{
$this->endpage=ceil($this->total/$this->pagesize);
return $this->endpage;
}
//获得$page
function getpage($page)
{
$this->page=$page?$page:1;
return $this->page;
}
//获得当前记录
function getcurentrecord()
{
$this->curentrecord=($this->page-1)*$this->pagesize;
return $this->curentrecord;
}
//上一页、下一页方式
function listpage()
{
if ($this->page<=$this->fisrtpage)//首页
{
echo "首页 ";
}else {
echo "<A href='$this->url ?page=$this->fisrtpage'>首页</A> ";
}
if ($this->page>$this->fisrtpage) {//上一页
$privious=$this->page-1;
echo "<A href='$this->url page=$privious'>上一页</A> ";
}
if ($this->page<=$this->endpage)//下一页
{
$next=$this->page+1;
echo "<A href='$this->url page=$next'>下一页</A> ";
}
if ($this->page<$this->endpage) {//尾页
echo "<A href='$this->url page=$this->endpage'>尾页</A> ";
}else {
echo "尾页";
}
}
//分页循环方式,数字显示
//分页循环方式,数字显示
function listcycle()
{
for ($i=1;$i<=$this->endpage;$i++)
{
if ($this->page==$i)
{
echo $i." ";
}else
{
echo "<A href='$this->url page=$i'>$i</A> ";
}
}
}
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询