Posted by Rich on 04/11/06 01:35
On 10 Apr 2006 06:56:41 -0700, Duderino82 wrote...
>
>I was wondering if there is a way to collect the names of the fields
>from a specific table. I think the soluction is to be researched in the
>sql code but maybe someone knows of a way to o so directly from php.
>
>Example.
>Table: Categories
>Field1: type1
>Field2: type2
>Field3: type3
>Field4: type4
>Field5: type5
>
>
>What I want is to be able to have an array (or an object) that cointans
>the name of the fields:
>
>array[0]=type1
>array[1]=type2
>array[2]=type3
>array[3]=type4
>array[4]=type5
>
>Any suggestions?
>
Depending on the SQL server you're using the command might be a little
different. As an example with MySQL I believe the syntax is..
DESCRIBE table_name;
Other SQL servers will have different commands. I think there's another though
in MySQL similar to...
SHOW COLUMNS FROM table_name;
Not sure how they differ so one may work out better for you when used in
conjunction with PHP.
Rich
--
Carry Forward Bandwidth! Included In All NewsGuy Accounts!
Don't lose what you don't use! - http://newsguy.com/overview.htm
Navigation:
[Reply to this message]
|