PHP DB Access Select

 

- Info:

- This tutorial shows how to use PHP to SELECT from Access DB.

 

- Example:

- Create PHP Console Application Read.php.

 

Read.php

<?php

 

#CONNECT TO DB.

$db = 'D:\Temp\PHP\guestbook.mdb';

$conn = new COM('ADODB.Connection');

$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");

#EXECUTE STATEMENT.

$sql = 'SELECT NAME FROM PEOPLE ORDER BY ID';

$rs = $conn->Execute($sql);

#DISPLAY RESULTS.

while(!$rs->EOF){

print($rs->Fields['NAME']->Value . "\n");

$rs->MoveNext();

}

 

?>