Page 1 of 1

When describing the structure of a table, how do you...

Posted: Fri Sep 27, 2002 11:50 am
by willing
Hello. I would be very grateful if anyone could help me with a question I have.

When describing the structure of a table using PHP, how do you call for the lengths of fields. For example, names varchar (??), how do I find out the set length of this field?

I thought the answer was using the ->max_length command, but that only tells you the greatest length of any data entered in to the field!

Pleeease help me!

:roll:

Posted: Fri Sep 27, 2002 12:27 pm
by kcomer
This way would work, may not be the easiest though.

run this query "SHOW FIELDS FROM `tblCode`"
then go through the result set, do some string manipulation with the Type column and it will give you the size.
Here's what the query returns.
Field,Type,Null,Key,Default,Extra
codeID,int(14),,PRI,0,
codeName,varchar(50),YES,,NULL,
codeActive,char(1),YES,,NULL,
codeSession,varchar(4),YES,,NULL,

Might help, might not.

Keith

Posted: Fri Sep 27, 2002 3:04 pm
by jason

Posted: Mon Sep 30, 2002 11:17 am
by willing
Thank you both for you solutions.