PHP Get database structure

Source: Internet
Author: User
Tags echo date

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><styletype= "Text/css"><!--body,table{font-size:13px;}Table{Table-layout:fixed;Emptyempty-cells:Show;Border-collapse:collapse;margin:0 Auto;Border:1px solid #cad9ea;}th{Height:22px;font-size:13px;Font-weight:Bold;Background-color:#CCCCCC;text-align:Center;}TD{Height:20px;}. Tabletitle{font-size:14px;Font-weight:Bold;}</style><title>Database structure</title></Head><Body><Divstyle= "margin:0 auto;width:880px; border:1px #006600 solid; font-size:12px; line-height:20px;"><Divstyle= "width:100%;height:30px; font-size:16px; font-weight:bold; text-align:center;">Network Database structure<BR/><Fontstyle= "font-size:14px; font-weight:normal;"><?php echo Date ("y-m-d h:i:s");?></Font></Div><?php$host = "localhost"; $username = "root"; $password = "root"; $dbname = "Ecsotre"; $dbconn =mysql_connect ($host, $ Username, $password); $sqlname = "Information_schema"; mysql_select_db ($sqlname, $dbconn); Session_Start (); $sql = "   SELECT * from tables where table_schema= ' ". $dbname." ' ORDER by table_name '; $result = mysql_query ($sql); while ($row =mysql_fetch_array ($result)) {//print_r ($row);?> <Divstyle= "margin:0 auto; width:100%; padding-top:10px;"><bclass= "Tabletitle">Table Name:<?php echo $row ["table_name"]?> </b> <BR/><?php echo $row ["Table_comment"]?></Div> <Tablewidth= "100%"Border= "1"><thead><thwidth= "The ">Serial number</TD><thwidth= "The ">Field name</TD><thwidth= "$">Field type</TD><thwidth= "a">Allow to empty</TD><thwidth= "The ">Default value</TD><th>Note</TD></thead><?PHP$SQL2 = "SELECT * from columns where table_name= '". $row ["table_name"]. "' ORDER by column_name '; $result 2 = Mysql_que   Ry ($sql 2); $num =0;while ($row 2=mysql_fetch_array ($result 2)) {$num = $num +1;//print_r ($row);?> <TR><TDAlign= "Center"><b><?php echo $num?></b></TD><TD><?php echo $row 2["column_name"]?></TD><TD><?php echo $row 2["Column_type"]?></TD><TDAlign= "Center"><?php echo $row 2["is_nullable"]?></TD><TDAlign= "Center"><?php echo $row 2["Column_default"]?></TD><TD><?php echo $row 2["Column_comment"]?></TD></TR><?php}?></Table><?Php}mysql_close ($dbconn);?></Div></Body></HTML>

PHP Get database structure

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.