/*
discuz
显示论坛表,结构
by lost63.com 2010.8.17
*/
$dbhost='localhost'; //服务器
$dbuser='root'; //用户名
$dbpw='myoa888'; //密码
$dbname='pipiqiu'; //数据库名
$tablepre='pre_'; //表前缀
header("Content-type:text/html; char=gb2312");
mysql_connect($dbhost,$dbuser,$dbpw) or die('数据库连接失败');
mysql_query("set names gb2312");
mysql_select_db($dbname) or die('找不到数据库');
echo '';
$tb_names=mysql_list_tables($dbname);
$tables=array(); //表名数组
/* 数据库所有表 */
while($row=mysql_fetch_row($tb_names)){
$tables[]=$row[0];
}
echo $dbname.'该数据库含有'.count($tables).'个表,显示如下:
';
echo '
foreach($tables as $v){
echo '
}
echo '';
/* 结构显示 */
echo '
======================= 结构显示 =======================
';for($i=0;$i
$query=mysql_query("select * from `".$tables[$i]."`");
while($row=mysql_fetch_field($query)){
$fd.=str_pad(" ",2).$row->name." ".$row->type."(".$row->max_length."),";
}
$fd=substr($fd,0,-1)."n";
$fd=str_replace(",",",n",$fd);
echo '
'.$tables[$i].' |
'.$fd.' |
unset($fd);
}
echo '
======================= 显示完毕 =======================
';?>