This is neat PHP short script which show all the Columns details for a table in your database. I use this snippet all the time. its simple but power that shows you details about a table columns.

UPDATE: As of 8/24/2022 I have updated this file, I have included in this post. You can download in the download section of this post. is a text file, you will have to change the file extention from .txt to .php to work. Be sure to change the username and password for the MYSQL host and other table parameters, follow the instructions.

here you go:

            $sqls="SHOW COLUMNS FROM TableName";
            $results = mysql_query($sqls ,$db);
            if ($myrow = mysql_fetch_array($results, MYSQL_ASSOC))  {
                $Columns['Fields'] = array();
                do{                   
                /* 
                    // EXAMPLE OF SQL COLUMN PROPERTIES
                    [Field] => id
                    [Type] => int(11)
                    [Null] => NO
                    [Key] => PRI
                    [Default] =>
                    [Extra] => auto_increment
                   
                    array('CatId' ,         'text' , 'value' , 'id' , 'class' , 'readonly="readonly"' , 'text'),   
                */                   
                    // SHOW EACH COLUMN PROPERTIES FOR DEBUGING:
                    //echo 'LINE '.__LINE__.' -<PRE> ';print_r($myrow);echo '</PRE>';
                    if($counter==1){$ReadOnly = 'readonly="readonly"'; $Columns['TableId'] = $myrow['Field'];}
                    else {$ReadOnly = '';}
                    if(strstr($myrow['Type'],'int')) $Type = 'text';
                    elseif(strstr($myrow['Type'],'text')) $Type = 'textarea';
                    //$counter++;
                    // these elements are from the Admin-Grid.php file and admin-inc/myadmin-add-edit.template.php for form fields
                    $Columns[$myrow['Field']] = $myrow;
                    $Columns[$myrow['Field']]['type'] =  $Type;
                    $Columns[$myrow['Field']]['value'] =  '';
                    $Columns[$myrow['Field']]['id'] =  '';
                    $Columns[$myrow['Field']]['readonly'] =  $ReadOnly;
                    $Columns[$myrow['Field']]['text'] =  '';
                   
                }while ($myrow = mysql_fetch_array($results, MYSQL_ASSOC));
            }else{
                {echo '<br>SQL ERROR <br>'.__FILE__.'  ---- LINE: '.__LINE__.'<br><span style="color:red">ERROR= '.mysql_error().'</span><hr><pre>';print_r($sql);echo '</pre>';exit;}
            }
            // you can use a foreach loop to loop througt the array
            foreach ($Columns as  $ColumnsKey => $ColumnsValue) {
                // do seomthing..
                echo '<h3>'.$ColumnsKey.'</h3><pre style="border:solid 1px #CCC;padding 5px; background-color:#EEE;">';print_r($ColumnsValue);echo'</pre><br>';
            }