Jump to Navigation

005 - To connect Oracle 10g XE

<?php
/* oci_fetch_all example */

$conn = oci_connect("hr", "hr", "localhost");

$stmt = oci_parse($conn, "select * from employees");

oci_execute($stmt);

$nrows = oci_fetch_all($stmt, $results);
if ($nrows > 0) {
echo "<table border=\"1\">\n";
echo "<tr>\n";
foreach ($results as $key => $val) {
echo "<th>$key</th>\n";
}
echo "</tr>\n";

for ($i = 0; $i < $nrows; $i++) {
echo "<tr>\n";
foreach ($results as $data) {
echo "<td>$data[$i]</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
} else {
echo "No data found<br />\n";
}
echo "$nrows Records Selected<br />\n";

oci_free_statement($stmt);
oci_close($conn);
?>

 

 

Oracle:


Main menu 2

Story | by Dr. Radut