title: mysql how to get maximum set length of each column
body: <p>I have an HTML form that I need to get the maximum set length of each of my fields in the corresponding MySQL database to set a proper value for the maxlength attribute of my text fields.  Is there a MySQL query that will give me those set maximum field lengths?</p>
  
  <p>The best solution I have is to query <code>SHOW COLUMNS FROM {database name}</code>, but that will return the field type with the maximum field length in parentheses (e.g. int(6), varchar(20), decimal(5,1), etc.), so then I would to use PHP or something to filter out only the maximum lengths, and there just seems like there's got to be a better way.</p>