html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

PHP通过ADO方式连接Access_PHP教程_编程技术

[ ] 已经帮助:人解决问题

PHP通过ADO方式连接Access数据库,如下代码:nukHTML5中文学习网 - HTML5先行者学习网

  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:nukHTML5中文学习网 - HTML5先行者学习网

  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. ?> 
nukHTML5中文学习网 - HTML5先行者学习网
nukHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助