Get the name of the column

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi there, this is very useful for me, so my issue is, when i use a
$result = sybase_query("sp_something")
while($r = sybase_fetch_array($result)) {

how can i get the name of the columns? for example for the raw data

Col1   Col2    Col3
hi        15       other value

how can i get the values "Col1", "Col2", "Col3"....
please, thanks for advanced.

Re: Get the name of the column

while ($row = sybase_fetch_assoc($result))
    while (current($row)) // or  while (current($row) != false)
        $data = current($row);
        $key = key($row);

        // do stuff here


Re: Get the name of the column

Jorge Reyes wrote:
Quoted text here. Click to load it

The fetch_array functions return an associative array, where the keys  
are the column names.  So to get an array of the column names, you can  
use the array_keys function:

$keys = array_keys($result);

More info:


Site Timeline