<? PHP/*** generate Mysql Data Dictionary * // configure the database $ dbserver = "127.0.0.1"; $ dbusername = ""; $ dbpassword = ""; $ database = ""; // other configurations $ Title = 'data dictionary '; $ mysql_conn = @ mysql_connect ("$ dbserver", "$ dbusername", "$ dbpassword ") or die ("MySQL connect is error. "); mysql_select_db ($ database, $ mysql_conn); mysql_query ('set names utf8', $ mysql_conn); $ table_result = mysql_query ('show tables ', $ mysql_conn ); // obtain all table names while ($ ROW = mysql_fe Tch_array ($ table_result) {$ tables [] ['table _ name'] = $ row [0];} // cyclically obtain the remarks of all tables and the foreach ($ tables as $ k => $ v) {$ SQL = 'select * from'; $ SQL. = 'information _ schema. tables '; $ SQL. = 'where'; $ SQL. = "table_name = '{$ V ['table _ name']}' and table_schema = '{$ database}'"; $ table_result = mysql_query ($ SQL, $ mysql_conn ); while ($ T = mysql_fetch_array ($ table_result) {$ tables [$ K] ['table _ comment'] = $ t ['Table _ comment'];} $ SQL = 'select * from'; $ SQL. = 'information _ schema. columns '; $ SQL. = 'where'; $ SQL. = "table_name = '{$ V ['table _ name']}' and table_schema = '{$ database}'"; $ fields = array (); $ field_result = mysql_query ($ SQL, $ mysql_conn); While ($ T = mysql_fetch_array ($ field_result) {$ fields [] = $ t ;} $ tables [$ K] ['column'] = $ fields;} mysql_close ($ mysql_conn); $ html = ''; // loop all tables foreach ($ Tables as $ k => $ v) {// $ HTML. = '<p> <H2> '. $ V ['table _ comment']. '</H2>'; $ HTML. = '<Table border = "1" cellspacing = "0" cellpadding = "0" align = "center">'; $ HTML. = '<caption> '. $ V ['table _ name']. ''. $ V ['table _ comment']. '</caption>'; $ HTML. = '<tbody> <tr> <TH> Field name </Th> <TH> data type </Th> <TH> default value </Th> <TH> allow non-null </Th> <TH> auto increment </Th> <TH> remarks </Th> </tr> '; $ HTML. = ''; foreach ($ V ['column '] as $ f) {$ HTML. = '<tr> <TD Class = "C1"> '. $ f ['column _ name']. '</TD>'; $ HTML. = '<TD class = "C2"> '. $ f ['column _ type']. '</TD>'; $ HTML. <TD class = "C3"> '. $ f ['column _ default']. '</TD>'; $ HTML. = '<TD class = "C4"> '. $ f ['is _ nulllable']. '</TD>'; $ HTML. = '<TD class = "C5"> '. ($ f ['extra '] = 'Auto _ secret '? 'Yes ':''). '</TD>'; $ HTML. = '<TD class = "C6"> '. $ f ['column _ comment']. '</TD>'; $ HTML. = '</tr>';} $ HTML. = '</tbody> </table> </P>';} // output echo '<HTML>