Page 1 of 1

Oracle - Loop through column names

Posted: Tue Feb 16, 2010 10:07 am
by dimxasnewfrozen
I'm working with a database that has about 60 columns. I need to check to see that there are values in each column.

Is there a way to loop through the columns in php as apposed to looping through the rows?
Something like:

while (column['$i'] = 'x') {
echo 'column name';
$i++;
}

where i would be a column name and not a number.

Re: Oracle - Loop through column names

Posted: Tue Feb 16, 2010 10:30 am
by dimxasnewfrozen
Ah HA!

I figured it out:

Code: Select all

for ($j = 0; $j < $nrows; $j++ ) {
    foreach( $results as $key => $value){
        if ($value[$j] == 'X') {
        echo $key . "<br />";
           }
         }
}
So ultimately, I get the number of rows, then loop through the columns for each row which in this case is an associative array considering Oracles query functions store it that way.