• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP通过ADO方式连接Access_php

php 搞代码 7年前 (2018-06-21) 272次浏览 已收录 0个评论

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. ?> 

欢迎大家阅读《PHP通过ADO方式连接Access_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP通过ADO方式连接Access_php
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址