oracle: fetch a query result into an array

From: Date: Wed, 18 Feb 2004 18:21:40 +0000
Subject: oracle: fetch a query result into an array
Groups: php.db 
Request: Send a blank email to php-db+get-33009@lists.php.net to get a copy of this message
Hello, 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(): &nbsp;&nbsp;&nbsp;".$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";

« previous php.db (#33009) next »