PHP通过ADO方式连接Access
程序员文章站
2024-04-03 19:14:46
...
PHP通过ADO方式连接Access数据库,如下代码:
- /span>
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- html xmlns="http://www.w3.org/1999/xhtml">
- head>
- meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- title>通过ADO方式连接ACCESS数据库 - www.cxybl.comtitle>
- link rel="stylesheet" type="text/css" href="style.css">
- style type="text/css">
- style>
- head>
- php
- include_once("conn.php");
- ?>
- body topmargin="0" leftmargin="0" bottommargin="0">
- table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
- tr>
- td height="25" bgcolor="#0099CC">div align="center" class="STYLE1">图书信息div>td>
- tr>
- tr>
- td bgcolor="#0099CC">table width="300" height="50" border="0" align="center"
- cellpadding="0" cellspacing="1">
- tr>
- td width="167" height="25" bgcolor="#FFFFFF">div align="center">书名div>td>
- td width="130" bgcolor="#FFFFFF">div align="center">出版社div>td>
- tr>
- php
- $sql="select * from tb_book";
- $rs=new com("adodb.recordset");
- $rs->open($sql,$conn,1,3);
- while(!$rs->eof)
- {
- ?>
- tr>
- td height="25" bgcolor="#FFFFFF">div align="center">
- php $fields=$rs->fields(bookname);echo $fields->value;?>div>td>
- td height="25" bgcolor="#FFFFFF">div align="center">
- php $fields=$rs->fields(pub);echo $fields->value;?>div>td>
- tr>
- php
- $rs->movenext;
- }
- ?>
- table>td>
- tr>
- table>
- body>
- html>
conn.php:
- $conn = new com("adodb.connection");
- $connstr="driver={microsoft access driver (*.mdb)}; dbq=". realpath("data/db_database12_185.mdb");
- $conn->open($connstr);
- ?>
上一篇: sql常用函数
下一篇: php 这个错误如何改正?