Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column types

Status
Not open for further replies.

axman505

Technical User
Jun 20, 2001
489
US
how would i select the field types of a table from php??

for ($i=0; $i < mysql_num_fields($result); $i++) {
$fieldname = mysql_field_name($result, 1);
$type = mysql_fieldtype($result, $i);
$len = mysql_field_len($result, $i);
$flags = mysql_field_flags($result, $i);
echo $fieldname.&quot; &quot;.$type.&quot; &quot;.$len.&quot; &quot;.$flags.&quot;<br>&quot;;
}


for the field type it returns values like string, int, blob

How do i get the values like varchar and char instead of string???
 
Yeah, mysql_field_name() and mysql_field_type() describe the data returned, not the columns of the table.

This is necessary -- return columns can be calculated, not just fetched.

If you want information on a table, issue the query &quot;DESCRIBE tablename&quot;. This will return table description information rather than return description information. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top