I'm just learning PHP. I would like to know if database programming in PHP can be done using MS-Access. Can any one help me with complete example codes please.
PHP Database Programming
Collapse
X
-
Tags: None
-
Here is sample code on a connection. Tested on WinXP, works fine.
[CODE=php]
<?
// url to database file
$db = 'C:\\Program Files\\Microsof t Office\\Office\ \Samples\\North wind.mdb';
// adodb connection
$conn = new COM('ADODB.Conn ection');
$conn->Open("Provider =Microsoft.Jet. OLEDB.4.0; Data Source=$db");
// sql code
$sql = 'SELECT ProductName, QuantityPerUnit , UnitPrice
FROM Products
ORDER BY ProductName';
$rs = $conn->Execute($sql );
// html
?>
<table>
<tr>
<th>Product Name</th>
<th>Quantity Per Unit</th>
<th>Unit Price</th>
</tr>
<? while (!$rs->EOF): ?>
<tr>
<td><?= $rs->Fields['ProductName']->Value ?></td>
<td><?= $rs->Fields['QuantityPerUni t']->Value ?></td>
<td><?= $rs->Fields['UnitPrice']->Value ?></td>
</tr>
<? $rs->MoveNext() ?>
<? endwhile ?>
</table>
<?
$rs->Close();
$conn->Close();
?>
[/CODE]niheel @ bytes
Comment