|
|
|
ช่วยดูวิธีติดต่อฐานข้อมูล MS Access ด้วย php ให้หน่อย |
|
|
|
|
|
|
|
ลืม....ถ้าช่วยได้ ช่วยทำตัวอย่างให้ดูด้วยนะครับ
|
|
|
|
|
Date :
21 ต.ค. 2547 12:59:33 |
By :
kritsada_31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำอย่างนี้ง่ายกว่านะ
<?
$db_connection = new COM("ADODB.Connection");
$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=";
$db_connstr.= realpath("test.mdb").";";
$db_connection->open($db_connstr);
$rs->open("select * from customer",$db_connection,1,3);
echo $rs->Recordcount();
echo "<table>";
while (!$rs->eof)
{
echo $rs[0]->value;
echo "<tr>";
echo "<td>";
$field = $rs->Fields("name");
echo $field->value;
echo "</td>";
$rs->Movenext();
echo "</tr>";
}
echo "</table>";
?>
|
|
|
|
|
Date :
26 มิ.ย. 2550 17:25:10 |
By :
rain |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & COM (ADO)</title>
</head>
<body>
<?php
$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("mydatabase.mdb"));
if($strConn)
{
echo "Database Connected";
}
else
{
echo "Database Connect Failed.";
}
$strConn->Close();
$strConn = null;
?>
</body>
</html>
Go to : PHP ADO Connect to Database
|
|
|
|
|
Date :
2011-06-06 21:49:22 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|