目前共有6篇帖子。
|
1樓
118.117.20.*
2015-6-14 14:18
<?php
$dsn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=E:\\Databases\data.mdb"; $conn = odbc_connect($dsn, "", "") or die ("Failed connecting to the Access Database"); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Microsoft Access 2003</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css"> <!-- body,td,th { font-size: 13px; font-family: Arial, Helvetica, sans-serif; } --> </style></head> <body> <?php $sql = "SELECT * FROM Products ORDER BY ProductID ASC"; $rs = odbc_exec($conn, $sql); ?> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#66CC00"> <tr> <td width="60" height="21" align="center" bgcolor="#E7FFD7">產品編號</td> <td height="21" align="center" bgcolor="#E7FFD7">產品名稱</td> <td width="200" align="center" bgcolor="#E7FFD7">產品描述</td> <td width="70" height="21" align="center" bgcolor="#E7FFD7">產品價格</td> </tr> <?php while ($row = odbc_fetch_array($rs)) { ?> <tr> <td width="60" height="28" align="center" bgcolor="#E7FFD7"><?=$row["ProductID"]?></td> <td height="28" align="center" bgcolor="#FFFFFF"><?=$row["ProductName"]?></td> <td width="200" align="center" bgcolor="#FFFFFF"><?=$row["ProductDescription"]?></td> <td width="70" height="28" align="center" bgcolor="#FFFFFF">$<?=$row["ProductPrice"]?></td> </tr> <?php } ?> </table> </body> </html> <?php odbc_close($conn); ?> |
|
|
2樓
118.117.20.*
2015-6-14 14:19
輸出內容: <!doctype html> |
|
|
3樓
118.117.20.*
2015-6-14 14:21
這是一個PHP連接Access 2003數據庫的示例。
|
|
|
4樓
118.117.20.*
2015-6-14 16:14
$conn = odbc_connect($dsn, "", "", SQL_CUR_USE_ODBC) 用SQL_CUR_USE_ODBC可以避免一些錯誤。 |
|
|
5樓
118.117.20.*
2015-6-14 16:18
... <p><?=odbc_num_rows($rs)?></p> |
|
|
6樓
118.117.20.*
2015-6-14 16:19
mysql_free_result() 仅需要在考虑到返回很大的结果集时会占用多少内存时调用。在脚本结束后所有关联的内存都会被自动释放。
|