mysql_fetch_fields()
MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)
This function returns an array of information about the fields in a results set. Here is an example:
...
mysql_query(mysql, "SELECT * FROM clients");
result = mysql_store_result(mysql);
num_fields = mysql_field_count(mysql);
MYSQL_FIELD *field;
field = mysql_fetch_fields(result);
for(i = 0; i < num_fields; i++)
{ printf("%u.%s \n", i, &field[i].name); }
...In addition to the .name key to extract the
column name, a program can specify .table for the
table name and .def for the default value of the
column.