Home >Backend Development >PHP Tutorial >PHP connection operation access database instance, access instance_PHP tutorial

PHP connection operation access database instance, access instance_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:59:13889browse

PHP connection operation access database instance, access instance

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 The connection with MySQL is relatively troublesome. 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.

/*
Create ADO connection
*/
$conn = @new COM("ADODB.Connection") or die ("ADO Connection failed.");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("DATUM/cnbt.mdb");
$conn->Open($connstr);
/*
Create recordset query
*/
$rs = @new COM("ADODB.RecordSet");
$rs->Open("select * from dbo_dirs",$conn,1,3);
/*
Loop to read data
*/
while(!$rs->eof){
echo "$rs->Fields["title"]->Value;
echo "
";
$rs->Movenext(); //Move the record set pointer down
}
$rs->close();
?>

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/976023.htmlTechArticlePHP connection operation access database instance, the access instance is because the PingSwitch made before is to be a front-end for WEB display, because a I started using the structure of Delphi and access, and the connection between Delphi and MySQL...
Statement:
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