php链接access数据库代码

<?php

$odbc = "Driver={Microsoft Access Driver (*.mdb)};Dbq=".realpath("test.mdb");
$conn = odbc_connect($odbc, '', '', SQL_CUR_USE_ODBC);
$sql ="select * from user";
$query = odbc_exec($conn, $sql);
$num = odbc_num_fields($query);
echo "<table><tr><th>ID</th><th>username</th><th>password</th></tr>";
while ($row = odbc_fetch_row($query))
{
echo "<tr>";
echo "<td>".odbc_result($query,"id")."</td>";
echo "<td>".odbc_result($query,"username")."</td>";
echo "<td>".odbc_result($query,"password")."</td>";
echo "</tr>";
}
echo "</table>";
?>

access数据库设计如下

php 链接access数据库_sql