Page 1 of 1
retrive field names
Posted: Wed Nov 30, 2005 12:38 pm
by ddragas
How to retrive all field names from db
Posted: Wed Nov 30, 2005 12:47 pm
by Burrito
desc %tablename%
Posted: Wed Nov 30, 2005 12:58 pm
by ddragas
Thnx for reply.
I think you didn't undersund my question.
What I want is to make loop and "echo" names of fields from table in db
| id | first_name | last_name | year_of_birth | etc |
Posted: Wed Nov 30, 2005 2:11 pm
by Chris Corbyn
Burrito was right. "describe tablename" or "show columns in tablename" both work ...
Code: Select all
$conn = mysql_connect();
mysql_select_db();
$query = "show columns in tablename";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
echo "$row[0]<br />\n";
}
mysql_close();
Posted: Wed Nov 30, 2005 2:29 pm
by ddragas
thank you for reply.
I'll try that
It was my mistake. I dod not understand what Burrito was going to tell me. Sory Burrito and than you both