Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-22-2008, 04:44 PM
Registered User
 
Join Date: Jul 2004
Posts: 224
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, 07:55 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,399
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
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

vB 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 08:28 PM
So Frustrated! 3 Column Layout Help musicsmysoul Programming and Scripting 5 05-10-2006 06:45 PM
Am I coding Sendmail correctly? NevadaSam Programming and Scripting 5 05-09-2006 11:20 AM
3 column layout problem pulsewidth Programming and Scripting 9 04-14-2006 06:31 PM
strip carriage returns & linefeed characters from form field amanxman Programming and Scripting 2 03-30-2006 06:52 AM


All times are GMT -5. The time now is 11:15 PM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

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