展开全部
//php连接access测试
define('ROOT',str_replace($_SERVER['PHP_SELF'],'',str_replace('\\','/',__FILE__)));
$conn=new com('adodb.connection');
$conn->Provider='microsoft.jet.oledb.4.0';
$conn->Open(ROOT.'MDB数据库路径');
$rs=new com('adodb.recordset');
$rs->Open('SELECT * FROM 数据表名',$conn,1,1);
$rs->PageSize=50;
$page=1;
if(!empty($_GET['page'])){
$page=$_GET['page'];
if($page<1)$page=1;
if($page>$rs->PageCount)$page=$rs->PageCount;
}
$rs->AbsolutePage=$page;
echo '<table width="100%"><tr>';
foreach( $rs->Fields as $name){
echo '<td>'.$name->Name.'</td>';
}
echo '</tr>';
for(;!$rs->EOF;$rs->MoveNext()){
echo '<tr>';
foreach( $rs->Fields as $name){
echo '<td>'.$name.'</td>';
}
echo '</tr>';
if($rs->AbsolutePosition>=$rs->AbsolutePage*$rs->PageSize)break;
}
echo '</tale>';
for($i=0;$i<$rs->PageCount;$i++){
echo '<a href="index.php?page='.($i+1).'"> '.($i+1).' </a>';
}
define('ROOT',str_replace($_SERVER['PHP_SELF'],'',str_replace('\\','/',__FILE__)));
$conn=new com('adodb.connection');
$conn->Provider='microsoft.jet.oledb.4.0';
$conn->Open(ROOT.'MDB数据库路径');
$rs=new com('adodb.recordset');
$rs->Open('SELECT * FROM 数据表名',$conn,1,1);
$rs->PageSize=50;
$page=1;
if(!empty($_GET['page'])){
$page=$_GET['page'];
if($page<1)$page=1;
if($page>$rs->PageCount)$page=$rs->PageCount;
}
$rs->AbsolutePage=$page;
echo '<table width="100%"><tr>';
foreach( $rs->Fields as $name){
echo '<td>'.$name->Name.'</td>';
}
echo '</tr>';
for(;!$rs->EOF;$rs->MoveNext()){
echo '<tr>';
foreach( $rs->Fields as $name){
echo '<td>'.$name.'</td>';
}
echo '</tr>';
if($rs->AbsolutePosition>=$rs->AbsolutePage*$rs->PageSize)break;
}
echo '</tale>';
for($i=0;$i<$rs->PageCount;$i++){
echo '<a href="index.php?page='.($i+1).'"> '.($i+1).' </a>';
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |