Hi I've been trying php for a while and now I would like to try to work with Oracle. Just for testing: I have a table called test
with four columns: | firstname | lastname | id | age |.
I try to display all the records on a html page but I don't get all the records. The last column's values are missing.
Here is the code:
Her $connection = OCILogon("username", "password", "ONW")
or die ("Couln't connect to oracle!");
$sql = "select * from test";
$sql_statement = OCIParse($connection,$sql)
or die("Couldn't parse statement.");
OCIExecute($sql_statement)
or die("Couldn't execute statement.");
$num_columns = OCINumCols($sql_statement);
echo '<TABLE BORDER="1" bordercolor="white" cellpadding="5" cellspacing="0">';
echo '<TR>
<TH>Name</TH>
<TH>firstname</TH>
<TH>Id</TH>
<TH>Age</TH>
</TR>';
while ($line = OCIFetch($sql_statement)) {
echo "<TR>";
for ($i = 1; $i < $num_columns; $i++) {
$column_value1 = OCIResult($sql_statement,$i);
// $column_value2 = OCIResult($sql_statement,$i+1);
// $column_value3 = OCIResult($sql_statement,$i+2);
// $column_value4 = OCIResult($sql_statement,$i+3);
echo "<TD>$column_value1</TD>";
// echo "<TD>$column_value2</TD>";
// echo "<td>$column_value3</td>";
// echo "<td>$column_value4</td>";
}
echo "</TR>";
}
echo "</TABLE>";
OCIFreeStatement($sql_statement);
OCILogoff($connection);
Does anyone know what I'm doing wrog?
Thanks, Jonathan