Home > PHP > Microsoft Access Database (MDB) from PHP

Microsoft Access Database (MDB) from PHP

This code demonstrates how to access a Microsoft Access Database (MDB) from PHP. Here I used PHP 5 for testing.


< ?_php

/* This example shows how to open and do operations on a Microsoft Access Database using PHP odbc functions */

$db_connection = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=E:rootphpDataBase.mdb", "ADODB.Connection", "password", "SQL_CUR_USE_ODBC");

echo "


Show all tables

";
$result = odbc_tables($db_connection);

while (odbc_fetch_row($result)) {
if(odbc_result($result,"TABLE_TYPE")=="TABLE") {
echo "
" . odbc_result($result,"TABLE_NAME");
}
}
echo "


SELECT code, comment from Degree

";

$res = odbc_exec($db_connection,"SELECT *FROM Degree");

$i = 0;
while (odbc_fetch_row($res)) {
$arr = odbc_fetch_array($res,$i);
echo "
" . $arr["code"] . ", ". $arr["comment"];
$i++;
}

echo "

Number of rows = $i

";

odbc_close($db_connection);
?>

VN:F [1.9.18_1163]
Rating: 5.0/5 (2 votes cast)
Microsoft Access Database (MDB) from PHP, 5.0 out of 5 based on 2 ratings

No related posts.

Categories: PHP