This article mainly introduces the PHP connection operation access database instance. This article directly gives the implementation code. Friends who need it can refer to it
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 the connection between Delphi and MySQL was relatively troublesome, in the end I could only choose to use the combination of PHP Access, which is quite strange. But it’s 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.