Home > php教程 > PHP源码 > body text

php+access 分页代码

WBOY
Release: 2016-06-08 17:27:23
Original
1228 people have browsed it
<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;

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template