How to fetching Column Names from Oracle using PHP
782988Jul 4 2010 — edited Jul 7 2010I am a novice with PHP and trying to plearn more........I need to fetch column names from oracle and display the column name as a header for result column. Query below does everything as expected but will not fetch column name. Is there are way to fetch column names from oracle
PHP 5.2 using OCI8
Any help is greately appreciated.
<?php
$co = oci_connect('user', 'pass', '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= ConnectionStringRemoved)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED) (SERVICE_NAME = ordb)))');
$st = oci_parse($conn, "Select ID, TNAME From SCH.TESTTABLE");
echo $st;
oci_execute($st);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($st, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>