@@ -344,6 +344,8 @@
  * TODO: Flag any available FKs that are not indexed.
  */
 function tw_analysis($form_state, $twtid, $flag=TW_COLS_NOIGNORE) {
+  global $db_url;
+
   $row = db_fetch_object(db_query("SELECT dbconnection, tablename, existing_view_data
                                    FROM {tw_tables}
                                    WHERE twtid=%d",
@@ -351,6 +353,16 @@
   $tablename = $row->tablename;
   $dbconnection = $row->dbconnection;
   $existing_view_data = $row->existing_view_data;
+  
+  // get the actual name of the database in question
+  db_set_active($dbconnection);
+  $db_name = parse_url($db_url);
+  $db_name = trim($db_name['path'], '/');
+  db_set_active();
+  
+  $description = db_result(db_query("SELECT TABLE_COMMENT FROM {information_schema.TABLES} WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'",
+    $db_name, $tablename));
+  $description = explode('; InnoDB free', $description);
 
   if (isset($_GET['reanalyze'])) {
     tw_perform_analysis($tablename, $dbconnection);
@@ -360,7 +372,15 @@
   $form['twtid'] = array('#type' => 'value', '#value' => $twtid);
   $form['tablename'] = array('#type' => 'value', '#value' => $tablename);
   $form['existing_view_data'] = array('#type' => 'value', '#value' => $existing_view_data);
+  $form['dbconnection'] = array('#type' => 'value', '#value' => $dbconnection);
 
+  $form['table_description'] = array(
+    '#type' => 'textarea',
+    '#rows' => 2,
+    '#title' => t('Table Description'),
+    '#default_value' => check_plain($description[0]),
+  );
+  
   switch ($flag) {
     case TW_COLS_ALL: 
       $flaglabel = t('All fields');
@@ -463,6 +483,7 @@
   );
   
   $form['title'] = array('#value' => t('Analysis of %table', array('%table' => $tablename)));
+  
   $form['header'] = array(
     '#type' => 'value',
     '#value' => array(
@@ -635,8 +656,9 @@
                array('html' => TRUE));
   $output .= '</div>';
   $output .= '<div>' . drupal_render($form['colcounts']) . '</div>';
-
   $output .= drupal_render($form['help']);
+  $output .= '<div>' . drupal_render($form['table_description']) . '</div>';
+
 
   if (isset($form['colname']) && is_array($form['colname'])) {
     foreach (element_children($form['colname']) as $colname) {
@@ -674,6 +696,12 @@
  * Implementation of hook_submit().
  */
 function tw_analysis_submit($form, &$form_state) {
+  global $db_url;
+
+  db_set_active($form_state['values']['dbconnection']);  
+  $description = db_query("ALTER TABLE `%s` COMMENT = '%s'", $form_state['values']['tablename'], $form_state['values']['table_description']);  
+  db_set_active();
+  
   $twtid = $form_state['values']['twtid'];
   foreach ($form_state['values']['cols'] as $key => $colname) {
     $newignore = $form_state['values']['ignorecol'][$colname] ? 1 : 0;
