Link to home
Start Free TrialLog in
Avatar of explorer1979
explorer1979

asked on

Do PHP can read and write data to MS Access database?

Hi all,

All also know that PHP + MySQL is the perfect suite. But since some reason, I am using MS Access for my web site's database...... since the web host haven't provide a MySQL DB for free, just have one ODBC Access DB

Now, I want to ask, do php also can using Access for DB, if it can how to connect to it, make recordset? Mainly, I just need read some data from the Access DB, not need to write back to the Access DB. How to do it??

Can anyone can make the code for me to reference? Since I am new in programming ....

Also want to learn more about PHP4/5, where to starting???? If not buy a book.

thx
ASKER CERTIFIED SOLUTION
Avatar of drakkarnoir
drakkarnoir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<<Also want to learn more about PHP4/5, where to starting???? If not buy a book.>>

search the internet for tutorials

another example:

<?php
$db = odbc_connect("YourDatabasePointer","YourUsername","YourPassword");
$rResult = odbc_exec ($db,"SELECT * FROM YourTableName");
?>
<html>
<head></head>
<body>
<table border="1" width="100%">
<tr>
<th>ID</th><th>Name</th><th>Address</th><th>Age</th
</tr>
<?php
while (($aRow = odbc_fetch_array($rResult)) !== False)
{      
?>
<tr>
      <td align="center"><?php echo $aRow['id']; ?></td>
      <td align="center"><?php echo $aRow['firstname']." ". $aRow['lastname'];?></td>
      <td align="center"><?php echo $aRow['address']; ?></td>
      <td align="center"><?php echo $aRow['age']; ?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>

this example uses a ms access db with the above field. it displays all records in db in table

Sean