

Oracle connection and data retrieval from PHP
Posted by: Andrei in Database, PHP, ProgrammingThis should be a guide for Oracle data manipulation from PHP.
First of all, the connection:
the sql string (we’ll use select in this example):
the loop that retrieves the data and publish as a HTML table:
$ora_cur = ora_do($ora_conn, $sql);
if ($ora_cur)
{
$numCols = ora_numcols($ora_cur);
//alternative coloring
$col1 = "#eeeeee";
$col2 = "#dddddd";
$toggle = "#eeeeee";
do {
$toggle == $col1? $toggle = $col2: $toggle = $col1;
?>
<tr bgcolor="<? echo $toggle;?>">
<td class="normal"><? echo ora_getcolumn($ora_cur,0);?></td>
<td class="normal"><? echo ora_getcolumn($ora_cur,1);?></td>
<td class="normal"><? echo ora_getcolumn($ora_cur,2);?></td>
<td class="normal"><? echo ora_getcolumn($ora_cur,3);?></td>
</tr>
<?
} while (ora_fetch($ora_cur));
}
?>
Andrei
http://www.webxpert.ro