PHP通過ADO方式串連Access

來源:互聯網
上載者:User

PHP通過ADO方式串連Access資料庫,如下代碼:

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  6. <title>通過ADO方式串連ACCESS資料庫 - www.cxybl.com</title> 
  7. <link rel="stylesheet" type="text/css" href="style.css"> 
  8. <style type="text/css"> 
  9. <!-- 
  10. .STYLE1 {color: #FFFFFF} 
  11. --> 
  12. </style> 
  13. </head> 
  14. <?php 
  15. include_once("conn.php"); 
  16. ?> 
  17. <body topmargin="0" leftmargin="0" bottommargin="0"> 
  18. <table width="300" border="0" align="center" cellpadding="0" cellspacing="0"> 
  19.   <tr> 
  20.     <td height="25" bgcolor="#0099CC"><div align="center" class="STYLE1">圖書資訊</div></td> 
  21.   </tr> 
  22.   <tr> 
  23.     <td bgcolor="#0099CC"><table width="300" height="50" border="0" align="center"  
  24.     cellpadding="0" cellspacing="1"> 
  25.       <tr> 
  26.         <td width="167" height="25" bgcolor="#FFFFFF"><div align="center">書名</div></td> 
  27.         <td width="130" bgcolor="#FFFFFF"><div align="center">出版社</div></td> 
  28.       </tr> 
  29.       <?php 
  30.        $sql="select * from tb_book"; 
  31.        $rs=new com("adodb.recordset"); 
  32.        $rs->open($sql,$conn,1,3); 
  33.        while(!$rs->eof) 
  34.        { 
  35.       ?> 
  36.       <tr> 
  37.         <td height="25" bgcolor="#FFFFFF"><div align="center"> 
  38.       <?php $fields=$rs->fields(bookname);echo $fields->value;?></div></td> 
  39.         <td height="25" bgcolor="#FFFFFF"><div align="center"> 
  40.       <?php $fields=$rs->fields(pub);echo $fields->value;?></div></td> 
  41.       </tr> 
  42.       <?php 
  43.          $rs->movenext; 
  44.        } 
  45.       ?> 
  46.     </table></td> 
  47.   </tr> 
  48. </table> 
  49. </body> 
  50. </html> 

conn.php:

 
  1. <?php 
  2. $conn = new com("adodb.connection");   
  3. $connstr="driver={microsoft access driver (*.mdb)}; dbq=". realpath("data/db_database12_185.mdb"); 
  4. $conn->open($connstr); 
  5. ?> 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.