How to fetch column names also from mssql in Php adodb

I am creating a web application that will connect to sql server through php adodb and will fetch records from database…BUT WHEN I AM FETCHING THE RECORD SET,I am unable to fetch the column names of rows…i am only getting the rows…

THE CODE I HAVE USED IS:

$sql="select * from project";
$result = $db->SelectLimit($sql, 4, 0); 


while (!$result->EOF) 
{
 
print $result->fields[0].' '.$result->fields[1].'<BR>'; 
     // fields[0] is surname, fields[1] is age
    $result->MoveNext();  //  Moves to the next row
  }

//How can i fetch the column names also…I mean every column name with its corresponding rows

If you truly need to, i suppose you could query for sp_columns tablename and read out of the column_name slot
But you already seem to know what is going to be in each index of the table, so i dont know why you would do this.

Can you please elaborate with some code

You’ve already got the code for a query. Run it with the query “sp_columns project”. One of the columns of the result is the column names of your table.

But again, you shouldnt need to do this unless for some reason you’re unaware of the table’s construction at runtime - which i cant think of a situation in which you would be.

ok

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.