A nice PHP page that outputs MySQL database table structure

Source: Internet
Author: User
Tags echo date

Often for convenience and intuitive, we will first directly in the database design tables, but then the structure and design of the table will be written in the design document, so that the code can be intuitive query, once the database table is very many, the field is very many, this is a very depressing job.

This is a beautiful PHP page, you can automatically output the MySQL database all the table structure, greatly facilitates the writing of the document, but also very convenient to code when the query. Of course, in the design of MySQL database tables and fields to fill in the details of the table and field notes, this is a very good habit, the output of this page is also the best effect.<! 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;
Empty-cells:show;
Border-collapse:collapse;
margin:0 Auto;
border:1px solid #cad9ea;
}
th{
height:22px;
font-size:13px;
Font-weight:bold;

Text-align:center;
}
td{
height:20px;
}
. tabletitle{font-size:14px; font-weight:bold;}

</style>
<title>Zuizen 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;"><? PHPecho Date ("y-m-d h:i:s");?> </font>
</div>
<?php

$dbconn =mysql_connect ("localhost", "root", "123");
$sqlname = "Information_schema";
mysql_select_db ($sqlname, $dbconn);
Session_Start ();

$sql = "SELECT * from tables where table_schema= ' Db_zuizen ' 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:<? PHPecho $row ["table_name"]?> </b> <BR/>
<? PHPecho $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
$sql 2 = "SELECT * from columns where table_name= '". $row ["table_name"]. "' ORDER by column_name ';
$result 2 = mysql_query ($sql 2);
$num = 0;
while ($row 2=mysql_fetch_array ($result 2))
{
$num = $num +1;
Print_r ($row);
?>

<TR>
<TDAlign= "Center"><b><? PHPEcho $num?> </b> </td>
<TD><? PHPecho $row 2["column_name"]?> </td>
<TD><? PHPecho $row 2["Column_type"]?> </td>
<TD Align= "Center"><? PHPecho $row 2["is_nullable"]?> </td>
<TDAlign= "Center"><? PHPecho $row 2["Column_default"]?> </td>
<TD><? PHPecho $row 2["Column_comment"]?> </td>
</tr>
<?php
}
?>
</table>
<?php
}
Mysql_close ($dbconn);
?>

</div>
</body>
</html> The following is the look of the run crawl:

Transferred from: http://blog.51cto.com/babyhe/1118372

A nice PHP page that outputs MySQL database table structure

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.