Home >Backend Development >PHP Tutorial >access database programming PHP connection access database
Copy the code The code is as follows:
/*
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 record set 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();
?>
The above introduces the access database programming and PHP connection to the access database, including the content of access database programming. I hope it will be helpful to friends who are interested in PHP tutorials.