The result of the "DESCRIBE" query is a dataset like that of any other query so ...
$query = "DESCRIBE montileaux_events "; if ($result = mysql_query($query)) { while ($field = mysql_fetch_array($result)) { foreach($field as $key => $val) { echo "$key : $val |"; } echo("<br>"); } } Tim Ward Internet Chess www.chessish.com <http://www.chessish.com> ---------- From: Kevin Stone [SMTP:[EMAIL PROTECTED]] Sent: 19 March 2002 23:21 To: [EMAIL PROTECTED] Subject: RE: [PHP] Re: Return the column names of MySQL table? Philip thanks for the tip-off to the mysql_list_fields() function.. that simplifies things quite a bit. Problem solved. :) I'm still wondering about the other method though. I noticed the "DESCRIBE table_name" method in the MySQL docs but couldn't figure out how to use it. Alone it seems to return information about only the first column... <? $query = "DESCRIBE montileaux_events "; $result = mysql_fetch_array(mysql_query($query)) foreach ($result as $key => $val) { echo "$key : $val <br>"; } ?> ----------- returns ------------- 0 : keynum Field : keynum 1 : int(11) Type : int(11) 2 : Null : 3 : PRI Key : PRI 4 : 5 : auto_increment Extra : auto_increment 6 : select,insert,update,references Privileges : select,insert,update,references ---------------------------------- keynum is the name of the frist column in the table. But beyond that there doesn't appear to be any data to increment through. The function returns this and only this. Am I using it wrong? Thanks, Kevin -----Original Message----- From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 19, 2002 4:02 PM To: Geoff Hankerson Cc: Kevin Stone; [EMAIL PROTECTED] Subject: [PHP] Re: Return the column names of MySQL table? Or if you want to do this within PHP use the mysql_list_fields function. On Tue, 19 Mar 2002, Geoff Hankerson wrote: > I believe it is: > describe tablename; > ----- Original Message ----- > From: "Kevin Stone" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, March 19, 2002 4:43 PM > Subject: Return the column names of MySQL table? > > > > Forgive me for the off topic question. This is a MySQL question.. has > > nothing to do with PHP directly. However I was not able to find an > > answer in the MySQL documentation, on Usenet, or the MySQL mailing list > > archives. Also MySQL.com's mail manager is on the fritz so I can't > > even subscribe to the MySQL email list. Anyway since many of you are > > familiar with SQL this is as good a place to ask this question as any. > > > > I simply need to return a list of column names of a MySQL table. What's > > the syntax to do that? > > > > Thanks, > > Kevin > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php