Follow the table comments in MySQL to generate the table head class

Source: Internet
Author: User

1<! Doctype html>234<meta http-equiv= "Content-type" content= "text/html; charset= "Utf-8"/>5 6 <body>7 <?php8 9 class Db_columnTen { Oneprotected static$db; Aprotected static function Initialdb ($dbName= ' mysql ') -     { -if (!self::$db[$dbName]) the         { -             $servername= "localhost"; -             $username= "Root"; -             $password= ""; + //Create connection -             $conn= New Mysqli ($servername,$username,$password,$dbName); +if ($conn->connect_error) { ADie ("Connection failed:".$conn->connect_error); at             } -Self::$db[$dbName] =$conn; -Self::$db[$dbName]->query ("SET NAMES UTF8"); -         } -Return self::$db[$dbName]; -     } inpublic static function Getcolumncomment ($dbName,$table) -     { to self::initialdb (' MySQL '); +         $sql= "SELECT -* the  from *Information_schema.COLUMNS $ WHEREPanax Notoginsengtable_name = ' $table ' and table_schema = ' $dbName ' "; -         $result= Self::$db[' MySQL ']->query ($sql); theWhile$row=$result->fetch_assoc ()) { +             $ret[] =$row; A         } theReturn$ret; +     } -public static function GetColumnInfo ($dbName,$table) $     { $SELF::INITIALDB ($dbName); -         $sql= "Show Columns from$table"; -         $result= Self::$db[$dbName]->query ($sql); theWhile$row=$result->fetch_assoc ()) { -             $ret[] =$row;Wuyi         } theReturn$ret; -     } Wu } -  About  $ $columnInfo= Db_column::getcolumncomment ("DBA", "TBA"); - echo ' <table> '; - echo ' <tr> '; -foreach$columnInfoAs$col) A { + echo ' <th> '; theEcho$col["Column_comment"]; - echo ' </th> '; $ } the echo ' <tr> '; the echo ' </table> '; the ?> the </body> -

Follow the table comments in MySQL to generate the table head class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.