1<?php
2
3// Create connection to Oracle
4$conn = oci_connect("phphol", "welcome", "//localhost/orcl");
5
6$query = 'select * from departments';
7$stid = oci_parse($conn, $query);
8$r = oci_execute($stid);
9
10// Fetch the results in an associative array
11print '<table border="1">';
12while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
13 print '<tr>';
14 foreach ($row as $item) {
15 print '<td>'.($item?htmlentities($item):' ').'</td>';
16 }
17 print '</tr>';
18}
19print '</table>';
20
21// Close the Oracle connection
22oci_close($conn);
23
24?>