$v)
{
$sql = 'SELECT * FROM ';
$sql .= 'information_schema.TABLES ';
$sql .= 'WHERE ';
$sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '{$database['DB_NAME']}'";
$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['DB_NAME']}'";
$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 = '';
// 循环所有表
//print_r($tables);
foreach($tables as $k => $v)
{
$html .= '| 字段名 | 数据类型 | 默认值 | 允许非空 | 自动递增 | 备注 | ' . $f['COLUMN_NAME'] . ' | '; $html .= '' . $f['COLUMN_TYPE'] . ' | '; $html .= '' . $f['COLUMN_DEFAULT'] . ' | '; $html .= '' . $f['IS_NULLABLE'] . ' | '; $html .= '' . ($f['EXTRA'] == 'auto_increment'?'是':' ') . ' | '; $html .= '' . $f['COLUMN_COMMENT'] . ' | '; $html .= ''; } $html .= '
|---|
生成时间:' . date('Y-m-d H:i:s') . '
'; echo $html; echo '总共:' . count($tables) . '个数据表
'; echo ''; ?>
上一篇:php中如何使用Header函数