<?php
header('Content-Type: text/html; charset=utf-8');
$db_host='127.0.0.1';
$db_username='root';
$db_password='suibianba';
$db_database = 'information_schema';
$connection=mysql_connect($db_host,$db_username,$db_password);//连接到数据库
mysql_query("set names 'utf8'");//编码转化
if(!$connection){
die("could not connect to the database:</br>".mysql_error());//诊断连接错误
}
$db_selecct=mysql_select_db($db_database);//选择数据库
if(!$db_selecct)
{
die("could not to the database</br>".mysql_error());
}
session_start();
$query="SELECT * FROM `TABLES` WHERE TABLE_SCHEMA='f2b_period' order by TABLE_NAME";//构建查询语句
$result=mysql_query($query);//执行查询
while($result_row=mysql_fetch_array($result)){ ?>
<div style="margin:0 auto; width:100%; padding-top:10px;">
<b class="tableTitle">表名: <?php echo $result_row["TABLE_NAME"] ?> </b> <?php echo $result_row["TABLE_COMMENT"] ?>
</div>
<table width="100%" border="1">
<thead>
<th width="70">序号</td>
<th width="170">字段名</td>
<th width="140">字段类型</td>
<th width="80">允许为空</td>
<th width="70">默认值</td>
<th>备注</td>
</thead>
<?php
$sql2 = "SELECT * FROM COLUMNS WHERE table_name='".$result_row["TABLE_NAME"]."' ORDER BY COLUMN_NAME";
$result2 = mysql_query($sql2);
$num=0;
while($row2=mysql_fetch_array($result2)) {
$num = $num+1; ?>
<tr>
<td><?php echo $num ?></td>
<td><?php echo $row2["COLUMN_NAME"] ?></td>
<td><?php echo $row2["COLUMN_TYPE"] ?></td>
<td><?php echo $row2["IS_NULLABLE"] ?></td>
<td><?php echo $row2["COLUMN_DEFAULT"] ?></td>
<td><?php echo $row2["COLUMN_COMMENT"] ?></td>
</tr>
<?php } ?>
</table>
<?php }
mysql_close($connection);
?>
header('Content-Type: text/html; charset=utf-8');
$db_host='127.0.0.1';
$db_username='root';
$db_password='suibianba';
$db_database = 'information_schema';
$connection=mysql_connect($db_host,$db_username,$db_password);//连接到数据库
mysql_query("set names 'utf8'");//编码转化
if(!$connection){
die("could not connect to the database:</br>".mysql_error());//诊断连接错误
}
$db_selecct=mysql_select_db($db_database);//选择数据库
if(!$db_selecct)
{
die("could not to the database</br>".mysql_error());
}
session_start();
$query="SELECT * FROM `TABLES` WHERE TABLE_SCHEMA='f2b_period' order by TABLE_NAME";//构建查询语句
$result=mysql_query($query);//执行查询
while($result_row=mysql_fetch_array($result)){ ?>
<div style="margin:0 auto; width:100%; padding-top:10px;">
<b class="tableTitle">表名: <?php echo $result_row["TABLE_NAME"] ?> </b> <?php echo $result_row["TABLE_COMMENT"] ?>
</div>
<table width="100%" border="1">
<thead>
<th width="70">序号</td>
<th width="170">字段名</td>
<th width="140">字段类型</td>
<th width="80">允许为空</td>
<th width="70">默认值</td>
<th>备注</td>
</thead>
<?php
$sql2 = "SELECT * FROM COLUMNS WHERE table_name='".$result_row["TABLE_NAME"]."' ORDER BY COLUMN_NAME";
$result2 = mysql_query($sql2);
$num=0;
while($row2=mysql_fetch_array($result2)) {
$num = $num+1; ?>
<tr>
<td><?php echo $num ?></td>
<td><?php echo $row2["COLUMN_NAME"] ?></td>
<td><?php echo $row2["COLUMN_TYPE"] ?></td>
<td><?php echo $row2["IS_NULLABLE"] ?></td>
<td><?php echo $row2["COLUMN_DEFAULT"] ?></td>
<td><?php echo $row2["COLUMN_COMMENT"] ?></td>
</tr>
<?php } ?>
</table>
<?php }
mysql_close($connection);
?>