#1 (permalink)  
Old 07-22-2008, 05:44 PM
Registered User
 
Join Date: Jul 2004
Posts: 247
print column names

Maybe this is posted in the wrong forum. I need to print out the column names of a database table with php.
Reply With Quote

  #2 (permalink)  
Old 07-22-2008, 08:55 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,438
You can run either of the following queries:
PHP Code:
DESC $table
or
PHP Code:
SHOW COLUMNS FROM $table 
Both queries will return the same results. Within those results, the column that you want will be called "Field".

Therefore, your PHP might look something like:
PHP Code:
$cols = array();
if(
$sql mysql_query("DESC mytable",$link)) {
while(
$rows mysql_fetch_assoc($sql)) {
$cols[] = $rows['Field'];
}

__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #3 (permalink)  
Old 11-19-2008, 09:54 AM
Registered User
 
Join Date: Nov 2008
Posts: 1
print list of column names

Please be VERY BASIC....How can I print a list of field names in a table?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Values For Form Elements With Unconventional Names curtiss Programming and Scripting 2 06-04-2006 09:28 PM
So Frustrated! 3 Column Layout Help musicsmysoul Programming and Scripting 5 05-10-2006 07:45 PM
Am I coding Sendmail correctly? NevadaSam Programming and Scripting 5 05-09-2006 12:20 PM
3 column layout problem pulsewidth Programming and Scripting 9 04-14-2006 07:31 PM
strip carriage returns & linefeed characters from form field amanxman Programming and Scripting 2 03-30-2006 07:52 AM


All times are GMT -5. The time now is 05:42 AM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter