首页  >  文章  >  php教程  >  php+access 分页代码

php+access 分页代码

WBOY
WBOY原创
2016-06-08 17:27:231226浏览
<script>ec(2);</script>

$scriptname = split('[/]',$_SERVER['SCRIPT_NAME']);
$filename = end($scriptname);
$MM_Conn_STRING="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("www.111cn.net/a.mdb") ." ;DefaultDir=". realpath(".");
$Conn=new COM("ADODB.Connection");
$RS =new COM("ADODB.RecordSet");//数据集
$Conn->open($MM_Conn_STRING);//链接打开数据源
$query="select * from doubt";
$RS->open($query,$Conn,1,1);//执行语句,返回记录集
$pagesize=$RS->Pagesize=3;//设置每页显示条数

if($RS->PageCount0){//防止数据库教程为空
if(!empty($_GET['page'])){
if($_GET['page'] $RS->AbsolutePage=1;
$nowpage=1;
}elseif($_GET['page']>$RS->PageCount){
$RS->AbsolutePage=$RS->PageCount;
$nowpage=$RS->PageCount;
}else{
$RS->AbsolutePage=$_GET['page'];
$nowpage=$_GET['page'];
}
}else{
$RS->AbsolutePage=1;
$nowpage=1;
}
}else{
$nowpage = 1;
$pagesize = 0;
}

echo "当前显示第".$nowpage."页 ";
echo "每页".$pagesize.'条 ';
echo "共有".$RS->RecordCount."条记录 ";
echo "共有".$RS->PageCount."页
 ";


for ($m=1; $m

{
echo "


    php+access 分页代码
姓名:".$RS->fields["username"]->value."
    问:".$RS->fields["biaoti"]->value."
    ".$RS->fields["wendate"]->value."


    问题:".$RS->fields["neirong"]->value."

      回复
   

";

$RS->MoveNext();


//if($RS->PageCount==0){
//echo "没有数据";
}


if($RS->PageCount0){//防止数据库为空
echo "首页 ";
if (!($nowpage echo "上一页 ";
}
if (!($nowpage>=$RS->PageCount)){
echo "下一页 ";
}
echo "PageCount.">尾页 ";
}
//释放资源
$Conn->Close();
$RS=NULL;
$Conn =NULL;

 

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn