Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sivamanim/687a81e9e16f670b0100e15cb96cd1e1 to your computer and use it in GitHub Desktop.
Save Sivamanim/687a81e9e16f670b0100e15cb96cd1e1 to your computer and use it in GitHub Desktop.
<?php
$db_username = ''; //username
$db_password = ''; //password
//path to database file
$database_path = $_SERVER["DOCUMENT_ROOT"] . "\access\accessdatabase.accdb";
//check file exist before we proceed
if (!file_exists($database_path)) {
die("Access database file not found !");
}
//create a new PDO object
$database = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$database_path; Uid=$db_username; Pwd=$db_password;");
$sql = "SELECT * FROM userdetails";
$result = $database->query($sql);
while ($row = $result->fetch()) {
echo '<pre>';
print_r($row);
echo '</pre>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment