Home > Backend Development > PHP Tutorial > PHP connects to access database, phpaccess database_PHP tutorial

PHP connects to access database, phpaccess database_PHP tutorial

WBOY
Release: 2016-07-13 10:00:12
Original
1019 people have browsed it

PHP connects to the access database, phpaccess database

Because the PingSwitch I made before was to be a front-end for WEB display, because the structure of Delphi and access was used at the beginning, and Delphi and MySQL The connection is relatively troublesome, and in the end I can only choose the combination of PHP Access, which is strange, but reasonable...

To connect to the access database in PHP, we must use ADO to connect, which is very similar to connecting to the database in ASP. A DEMO is given below for your reference.

<&#63;PHP
/*
创建ADO连接
*/
$conn = @new COM("ADODB.Connection") or die ("ADO Connection faild.");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("DATUM/cnbt.mdb");
$conn->Open($connstr);
/*
创建记录集查询
*/
$rs = @new COM("ADODB.RecordSet");
$rs->Open("select * from dbo_dirs",$conn,1,3);
/*
循环读取数据
*/
while(!$rs->eof){
 echo "$rs->Fields["title"]->Value;
 echo "<br/>";
 $rs->Movenext(); //将记录集指针下移
}
$rs->close();
&#63;>
Copy after login

There will be no problem running this way...

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/974657.htmlTechArticlePHP connects to the access database. The phpaccess database is because the PingSwitch made before is to be a front-end for WEB display, because it was used at the beginning The structure of Delphi and access is understood, and the connection between Delphi and MySQL is...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template