--- Daniel Israel <[EMAIL PROTECTED]> wrote:

> 1. When I do a MySQL query, is there a way to get the returned columns in
> the query without fetching a row?  Currently, what I'm doing is fetching a
> row of data and getting the keys from the array.  I'd like to do it without
> fetching  the row.  Is this possible?
> 
> 2. If #1 above is indeed possible, is this only possible when I get returned
> rows or can I do it when there are no matching rows in the query?
> 
> Thanks for any help!
> 
> -D. Israel

If you have at least one row of data you could get the column names through a
query like this:

SELECT * FROM table_name LIMIT 1;

However, in many applications this may not be practical because the table may
be empty.  You could use MySQL to describe the table for you and parse the
results you want:

DESC table_name;

There are some MySQL functions in PHP which can be used for this purpose but in
looking at the examples on http://php.net/mysql_fetch_field they seem more
complex than is necessary to achieve the goal.

James

Reply via email to