PHP+ACCESS获取数据库中最后10条数据


PHP读取ACCESS数据库中最后10条数据(测试用数据库文件test.mdb这里下载),程序代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?php 
$conn = new com("ADODB.Connection"); 
$conn_str = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath("test.mdb"); 
 
$conn->Open($conn_str); 
$rs = new com("ADODB.RecordSet"); 
$rs->Open("select top 10 id,title from www_1500km_com order by id desc ", $conn,1,1); 
 
while(! $rs->eof){ 
  echo $rs->Fields("id")->value .','.$rs->Fields("title")->value .'<hr>'; 
  $rs->MoveNext(); 
}
 
$rs->Close(); 
$rs=null; 
 
$conn->Close(); 
$conn=null; 
?> 

测试结果如下图: