I'm a php beginner and not succeed in fetching an oracle query result into an array. I want to load the colum names of a table (from an Oracle9i) into a <select>-field. There is something working, but only the last column name appears in the select field and is wraped by each letter.
For instense acw_fid_lab:
___
|non|
|all|
|A |
|C |
.
. and so on.
What are my mistakes? If anyone could suggest me how to solve it or using a better approach...
Thank you, Torsten
---------------------------------------------------
My last version (I also tried OCIFetchInto before):
---------------------------------------------------
function fill_select($table_name)
{
$connect = @OCILogon("", "", "");if(!$connect)
{
$err_oci = OCIError();
echo "(2) No connection - OCIError(): ".$err_oci["message"];
echo "<p>";
}
else
{
$sql_table_names = "SELECT column_name FROM user_tab_columns
WHERE table_name = '".$table_name."'";
$stmt = OCIParse($connect, $sql_table_names);
OCIExecute($stmt);
$column_name = array();
$counter = 0; while(OCIFetch($stmt))
{
$column_name = OCIResult($stmt,'COLUMN_NAME');
$counter++;
} if($counter == 0)
{
$column_name[0] = "nothing found";
}
OCIFreeStatement($stmt);
OCILogOff($connect);
return($column_name);} }
# This is a cut-out from that file I call the function from
echo " <td>\n";
echo " <select name=\"chemistry\" size=\"12\" multiple>\n";
echo " <option>none</option>\n";
echo " <option>all</option>\n";
$table_name = "AN_CHEMISTRY_WATER";
$count = (int) count_table_columns($table_name);
$column_names = fill_select($table_name);
for($i=1; $i<=$count; $i++)
{
echo "<option>",$column_names[$i],"</option>\n";
}
echo " </select>\n";
echo " </td>\n";-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
