README.md
December 5, 2022 ยท View on GitHub
Description
This is an example of how you can pull data from a Microsoft Access database through ADO. Windows only.
More Info
| Submitted On | |
| By | Daniel M. Hendricks |
| Level | Intermediate |
| User Rating | 4.8 (38 globes from 8 users) |
| Compatibility | PHP 4.0 |
| Category | Databases |
| World | PHP |
| Archive File |
Source Code
<?
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\inetpub\\wwwroot\\php\\mydb.mdb");
// SQL statement to build recordset.
$rs = $conn->Execute("SELECT myfield FROM mytable");
echo "<p>Below is a list of values in the MYDB.MDB database, MYABLE table, MYFIELD field.</p>";
// Display all the values in the recordset
while (!$rs->EOF) {
$fv = $rs->Fields("myfield");
echo "Value: ".$fv->value."<br>\n";
$rs->MoveNext();
}
$rs->Close();
?>