//-------------------------------------------------主体--------------------------------------------------
ljh_system_header();
/*
-------------------------配置数据库参数
*/
if(isset($HTTP_GET_VARS[setup])){
if($HTTP_GET_VARS[err]) echo "<p style='text-align:center'><font color=red>".urldecode($HTTP_GET_VARS[err])."</font></p>";
$para_setup_arr = ljh_get_para();
echo "<form name=f method=post action='".$HTTP_SERVER_VARS[PHP_SELF]."' style='text-align:center'>\n";
echo "<p style='font-weight:bold'>数据库参数配置</p>";
echo "数据库Ip[:Port]:<input name=para_ip value='".$para_setup_arr[0]."'><BR>\n";
echo "数据库登陆用户名:<input name=para_user value='".$para_setup_arr[1]."'><BR>\n";
echo "数据库登陆密 码:<input name=para_password type=password><BR><BR>\n";
echo "<input type=submit name='para_setup' value='提交设置'> ";
echo "<input type=button name='back_url' value='返回前一页' onclick='top.history.go(-1)'>";
echo "</form>\n";
ljh_system_bottom();
die();
}
if(isset($HTTP_POST_VARS[para_setup])){
if(@mysql_connect($HTTP_POST_VARS[para_ip],$HTTP_POST_VARS[para_user],$HTTP_POST_VARS[para_password])){
ljh_save_para($HTTP_POST_VARS[para_ip],$HTTP_POST_VARS[para_user],$HTTP_POST_VARS[para_password]);
header("Location:".$HTTP_SERVER_VARS[PHP_SELF]);
}else{
header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接到数据库,请重新设置!"));
}
}/*
--------------------------生成结构表
*/
if($HTTP_POST_VARS[startGetStruts]){
$db_target = $HTTP_POST_VARS['db_name'];
$db_para_arr = ljh_get_para();
@mysql_pconnect($db_para_arr[0],$db_para_arr[1],$db_para_arr[2]) or header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup=1&err=".urlencode("无法连接数据库!请重新设置")); for($n=0;$n<count($HTTP_POST_VARS[table_arr]);$n++){
//--------------------fields
$table = $HTTP_POST_VARS[table_arr][$n];
$table_filed_rs = @mysql_db_query($db_target,"show fields from {$table}");
if(!$table_filed_rs){
echo "<p><font color=red>读取表{$table}结构失败:<BR>".mysql_error()."</font></p>";
continue;
}
echo "<p> </p><p style='font-weight:bold'>数据表{$table}结构:</p>\n";
echo "字段结构表:<BR>\n";
echo $para_table_style['innerHTML']."\n";
echo "\t".$para_table_style['headerTr']."\n";
foreach($para_table_field as $k=>$v){
echo "\t\t<TD width=".$v[1].">".$v[0]."</TD>\n";
}
echo "\t</TR>\n";
while($t=@mysql_fetch_array($table_filed_rs)){
echo "\t".$para_table_style['normalTr']."\n"; echo "\t\t<TD>";
echo $t[Field];
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_wordwrap($t['Type'], 12, "<br>");
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_get_scope_str($t['Type']);
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo strlen($tt=ljh_wordwrap($t['Default'], 12, "<br>"))==NULL?'空':$tt;
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_key_name($t['Key']).($t['Extra']=='auto_increment'?"<BR>自动增长":'');
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ' ';
echo "\t\t</TD>\n"; echo "\t</TR>\n";
}
echo "</TABLE>\n";
if(!$HTTP_POST_VARS[if_index]) continue;
//-----------------index
$constraint_rs = @mysql_db_query($db_target,"show keys from $table");
if(!$constraint_rs){
echo "<p><font color=red>读取表{$table}索引失败:<BR>".mysql_error()."</font></p>";
continue;
}
$PK=array();$UK=array();$KEY=array();
while($con=mysql_fetch_object($constraint_rs)){
if($con->Key_name=="PRIMARY")
$PK[]=$con->Column_name;
if($con->Non_unique=="0"&&$con->Key_name!="PRIMARY")
$UK[$con->Key_name][]=$con->Column_name;
if($con->Non_unique=="1")
$KEY[$con->Key_name][]=$con->Column_name;
}
if(count($PK) || count($UK) || count($KEY)){
echo "<BR>索引结构表:<BR>\n";
echo $para_table_style['innerHTML']."\n";
echo "\t".$para_table_style['headerTr']."\n";
echo "\t\t<TD width=".$para_table_index['Type'][1].">".$para_table_index['Type'][0]."</TD>\n";
echo "\t\t<TD width=".$para_table_index['KeyName'][1].">".$para_table_index['KeyName'][0]."</TD>\n";
echo "\t\t<TD width=".$para_table_index['KeyField'][1].">".$para_table_index['KeyField'][0]."</TD>\n";
echo "\t</TR>\n"; if(count($PK)){
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>主键</TD>\n";
echo "\t\t<TD>PRIMARY</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($PK,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
if(count($UK)){
while(list($ke,$va)=@each($UK)){ //add UK
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>唯一</TD>\n";
echo "\t\t<TD>".$ke."</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($va,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
}
if(count($KEY)){
while(list($ke,$va)=@each($KEY)){ //add KEY
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>索引</TD>\n";
echo "\t\t<TD>".$ke."</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($va,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
}
$result=substr($result,0,-(strlen(",$enter")))."$enter);$enter";
echo "</TABLE>\n";
} }
echo "<p> </p>";
ljh_system_bottom();
die();
}//-------------------------------------默认,列出数据库
$db_para_arr = ljh_get_para();
if(!count($db_para_arr)) header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接数据库,请设置数据库参数!"));
$db_link = @mysql_connect($db_para_arr[0],$db_para_arr[1],$db_para_arr[2]);
if(!$db_link) header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接数据库,请设置数据库参数!"));
//获取某数据库的表
if($HTTP_GET_VARS[getTableDb]){
$db_table_rs = @mysql_list_tables($HTTP_GET_VARS[getTableDb]);
$db_tables_html .= "<table id='tb_".$HTTP_GET_VARS[getTableDb]."' border=1 cellspacing=0 cellpadding=0 borderColor=#000000 bordercolordark=#000000 style='border-collapse:collapse;font-size:12px;'>";
// $db_tables_html .= "<form name=frm"。" action='".$HTTP_POST_VARS[PHP_SELF]."' method=post>";
$db_tables_html .= "<TR bgColor=#E3E3E3 height=30 style='font-weight:bold;text-align:center'><td width=350 align=center>数据表排列顺序</td></TR>";
while(list($table)=mysql_fetch_row($db_table_rs)){
$db_tables_html .= "<tr><td align=center><input size=25 name='table_arr[]' value='".$table."'></td></tr>";
}
$db_tables_html .= "</table>";
echo "<script>parent.document.all.tableCase.innerHTML=\"".$db_tables_html."\";</script>";
echo "<script>parent.LJH_DynTbl('tb_".$HTTP_GET_VARS[getTableDb]."');\n</script>";
die();
}
$db_list = mysql_list_dbs($db_link);
while ($row = mysql_fetch_object($db_list)){
$db_opt.="<option value='".$row->Database."'>".$row->Database;
}
?>
<form name=frm action="<?=$HTTP_POST_VARS[PHP_SELF]?>" method=post>
<TABLE width=770 align=center>
<TR height=300>
<TD align=center width=40%>选择数据库:<BR>
<select name=db_name style="width:95%;height:95%" size="15" onchange="display_tbl(this.value)">
<?=$db_opt?>
</select>
</TD>
<TD width=60% id="tableCase">
</TD>
</TR>
<TR>
<TD colspan=2 align=center>
选项:
<input type=checkbox checked name="if_index" value=1>
是否显示索引结构表
</TD>
</TR>
<TR>
<TD colspan=2 align=center height=60>
<input type="submit" name="startGetStruts" value="列出当前数据库结构">
<input type="button" name="resetPara" value="重新设置数据库参数" onclick="top.location='<?=$HTTP_SERVER_VARS[PHP_SELF]?>?setup'">
</TD>
</TR>
</TABLE>
</form>
<iframe name=frmGetTableList frameborder=0 width=0 height=0></iframe>
ljh_system_header();
/*
-------------------------配置数据库参数
*/
if(isset($HTTP_GET_VARS[setup])){
if($HTTP_GET_VARS[err]) echo "<p style='text-align:center'><font color=red>".urldecode($HTTP_GET_VARS[err])."</font></p>";
$para_setup_arr = ljh_get_para();
echo "<form name=f method=post action='".$HTTP_SERVER_VARS[PHP_SELF]."' style='text-align:center'>\n";
echo "<p style='font-weight:bold'>数据库参数配置</p>";
echo "数据库Ip[:Port]:<input name=para_ip value='".$para_setup_arr[0]."'><BR>\n";
echo "数据库登陆用户名:<input name=para_user value='".$para_setup_arr[1]."'><BR>\n";
echo "数据库登陆密 码:<input name=para_password type=password><BR><BR>\n";
echo "<input type=submit name='para_setup' value='提交设置'> ";
echo "<input type=button name='back_url' value='返回前一页' onclick='top.history.go(-1)'>";
echo "</form>\n";
ljh_system_bottom();
die();
}
if(isset($HTTP_POST_VARS[para_setup])){
if(@mysql_connect($HTTP_POST_VARS[para_ip],$HTTP_POST_VARS[para_user],$HTTP_POST_VARS[para_password])){
ljh_save_para($HTTP_POST_VARS[para_ip],$HTTP_POST_VARS[para_user],$HTTP_POST_VARS[para_password]);
header("Location:".$HTTP_SERVER_VARS[PHP_SELF]);
}else{
header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接到数据库,请重新设置!"));
}
}/*
--------------------------生成结构表
*/
if($HTTP_POST_VARS[startGetStruts]){
$db_target = $HTTP_POST_VARS['db_name'];
$db_para_arr = ljh_get_para();
@mysql_pconnect($db_para_arr[0],$db_para_arr[1],$db_para_arr[2]) or header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup=1&err=".urlencode("无法连接数据库!请重新设置")); for($n=0;$n<count($HTTP_POST_VARS[table_arr]);$n++){
//--------------------fields
$table = $HTTP_POST_VARS[table_arr][$n];
$table_filed_rs = @mysql_db_query($db_target,"show fields from {$table}");
if(!$table_filed_rs){
echo "<p><font color=red>读取表{$table}结构失败:<BR>".mysql_error()."</font></p>";
continue;
}
echo "<p> </p><p style='font-weight:bold'>数据表{$table}结构:</p>\n";
echo "字段结构表:<BR>\n";
echo $para_table_style['innerHTML']."\n";
echo "\t".$para_table_style['headerTr']."\n";
foreach($para_table_field as $k=>$v){
echo "\t\t<TD width=".$v[1].">".$v[0]."</TD>\n";
}
echo "\t</TR>\n";
while($t=@mysql_fetch_array($table_filed_rs)){
echo "\t".$para_table_style['normalTr']."\n"; echo "\t\t<TD>";
echo $t[Field];
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_wordwrap($t['Type'], 12, "<br>");
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_get_scope_str($t['Type']);
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo strlen($tt=ljh_wordwrap($t['Default'], 12, "<br>"))==NULL?'空':$tt;
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ljh_key_name($t['Key']).($t['Extra']=='auto_increment'?"<BR>自动增长":'');
echo "\t\t</TD>\n"; echo "\t\t<TD>";
echo ' ';
echo "\t\t</TD>\n"; echo "\t</TR>\n";
}
echo "</TABLE>\n";
if(!$HTTP_POST_VARS[if_index]) continue;
//-----------------index
$constraint_rs = @mysql_db_query($db_target,"show keys from $table");
if(!$constraint_rs){
echo "<p><font color=red>读取表{$table}索引失败:<BR>".mysql_error()."</font></p>";
continue;
}
$PK=array();$UK=array();$KEY=array();
while($con=mysql_fetch_object($constraint_rs)){
if($con->Key_name=="PRIMARY")
$PK[]=$con->Column_name;
if($con->Non_unique=="0"&&$con->Key_name!="PRIMARY")
$UK[$con->Key_name][]=$con->Column_name;
if($con->Non_unique=="1")
$KEY[$con->Key_name][]=$con->Column_name;
}
if(count($PK) || count($UK) || count($KEY)){
echo "<BR>索引结构表:<BR>\n";
echo $para_table_style['innerHTML']."\n";
echo "\t".$para_table_style['headerTr']."\n";
echo "\t\t<TD width=".$para_table_index['Type'][1].">".$para_table_index['Type'][0]."</TD>\n";
echo "\t\t<TD width=".$para_table_index['KeyName'][1].">".$para_table_index['KeyName'][0]."</TD>\n";
echo "\t\t<TD width=".$para_table_index['KeyField'][1].">".$para_table_index['KeyField'][0]."</TD>\n";
echo "\t</TR>\n"; if(count($PK)){
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>主键</TD>\n";
echo "\t\t<TD>PRIMARY</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($PK,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
if(count($UK)){
while(list($ke,$va)=@each($UK)){ //add UK
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>唯一</TD>\n";
echo "\t\t<TD>".$ke."</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($va,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
}
if(count($KEY)){
while(list($ke,$va)=@each($KEY)){ //add KEY
echo "\t".$para_table_style['normalTr']."\n";
echo "\t\t<TD>索引</TD>\n";
echo "\t\t<TD>".$ke."</TD>\n";
echo "\t\t<TD>".ljh_wordwrap(implode($va,","),35,"<BR>")."</TD>\n";
echo "\t</TR>\n";
}
}
$result=substr($result,0,-(strlen(",$enter")))."$enter);$enter";
echo "</TABLE>\n";
} }
echo "<p> </p>";
ljh_system_bottom();
die();
}//-------------------------------------默认,列出数据库
$db_para_arr = ljh_get_para();
if(!count($db_para_arr)) header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接数据库,请设置数据库参数!"));
$db_link = @mysql_connect($db_para_arr[0],$db_para_arr[1],$db_para_arr[2]);
if(!$db_link) header("Location:".$HTTP_SERVER_VARS[PHP_SELF]."?setup&err=".urlencode("无法连接数据库,请设置数据库参数!"));
//获取某数据库的表
if($HTTP_GET_VARS[getTableDb]){
$db_table_rs = @mysql_list_tables($HTTP_GET_VARS[getTableDb]);
$db_tables_html .= "<table id='tb_".$HTTP_GET_VARS[getTableDb]."' border=1 cellspacing=0 cellpadding=0 borderColor=#000000 bordercolordark=#000000 style='border-collapse:collapse;font-size:12px;'>";
// $db_tables_html .= "<form name=frm"。" action='".$HTTP_POST_VARS[PHP_SELF]."' method=post>";
$db_tables_html .= "<TR bgColor=#E3E3E3 height=30 style='font-weight:bold;text-align:center'><td width=350 align=center>数据表排列顺序</td></TR>";
while(list($table)=mysql_fetch_row($db_table_rs)){
$db_tables_html .= "<tr><td align=center><input size=25 name='table_arr[]' value='".$table."'></td></tr>";
}
$db_tables_html .= "</table>";
echo "<script>parent.document.all.tableCase.innerHTML=\"".$db_tables_html."\";</script>";
echo "<script>parent.LJH_DynTbl('tb_".$HTTP_GET_VARS[getTableDb]."');\n</script>";
die();
}
$db_list = mysql_list_dbs($db_link);
while ($row = mysql_fetch_object($db_list)){
$db_opt.="<option value='".$row->Database."'>".$row->Database;
}
?>
<form name=frm action="<?=$HTTP_POST_VARS[PHP_SELF]?>" method=post>
<TABLE width=770 align=center>
<TR height=300>
<TD align=center width=40%>选择数据库:<BR>
<select name=db_name style="width:95%;height:95%" size="15" onchange="display_tbl(this.value)">
<?=$db_opt?>
</select>
</TD>
<TD width=60% id="tableCase">
</TD>
</TR>
<TR>
<TD colspan=2 align=center>
选项:
<input type=checkbox checked name="if_index" value=1>
是否显示索引结构表
</TD>
</TR>
<TR>
<TD colspan=2 align=center height=60>
<input type="submit" name="startGetStruts" value="列出当前数据库结构">
<input type="button" name="resetPara" value="重新设置数据库参数" onclick="top.location='<?=$HTTP_SERVER_VARS[PHP_SELF]?>?setup'">
</TD>
</TR>
</TABLE>
</form>
<iframe name=frmGetTableList frameborder=0 width=0 height=0></iframe>
解决方案 »
- css+div
- 关于美工的小问题
- 登录N次失败以后N分钟内禁止登录
- 求一个正则表达试 问了很久了
- php可不可以实现判断字符串是否是乱码的功能吗?
- 请问如何在linux下看php的电子书或文档
- 我在phpe.net找到一个phpmailer的类,我该如何在我的PHP页面中使用他呢?
- 如何用php语法进行文件的直接下载,高手请进
- 谁能给段php程序测试一下mysql的安装情况?
- 哪有用户认证系统源码?(php+mysql越精简越好!)
- 正在努力学PHP,刚接触类这个东西,太多不明白,请大家帮忙这个为何无输出?
- PHP,日期“yyyy-mm-dd”的累加????怎么样才能实现!!!!!MM这厢有礼了!!!!
<!--
function display_tbl(tbl)
{
document.all.frmGetTableList.src = "<?=$HTTP_SEVER_VARS[PHP_SELF]?>?getTableDb="+tbl;
return;
var pre = "tb_";
var s = document.getElementsByTagName("TABLE");
for(var i=0;i<s.length;i++){
if(s[i].id.substr(0,pre.length)==pre){
if(s[i].id==(pre+tbl)){
s[i].style.display = "";
}else{
s[i].style.display = "none";
}
}
}}
function LJH_DynTbl(tId)
{
var a = document.getElementById(tId);
a.colsNum = a.rows[a.rows.length-1].cells.length; //列数
var optHtml = "<font color=blue size=4 style='font-weight:bold;cursor:hand' title='删此行'>-</font> "
+"<font color=blue size=2 style='font-weight:bold;cursor:hand' title='上移一行'>↑</font> "
+"<font color=blue size=2 style='font-weight:bold;cursor:hand' title='下移一行'>↓</font>"; function appendOptCell()
{
for(var n=0;n<a.rows.length;n++){
a.rows[n].insertCell();
a.rows[n].cells[a.colsNum].innerHTML = (n==0)?" ":optHtml;
if(n!=0){
a.rows[n].cells[a.colsNum].attachEvent("onselectstart",returnfalse);
var optNode = a.rows[n].cells[a.colsNum].childNodes;
optNode[0].attachEvent("onclick",delRow);
optNode[2].attachEvent("onclick",rowMovePre);
optNode[4].attachEvent("onclick",rowMoveNext);
}
}
}
function delRow() //delete one line
{
if(a.rows.length<=2) return;
var r = event.srcElement;
while(r.tagName!="TR") r = r.parentElement;
a.deleteRow(getRowIndex());
}
function rowMoveNext()
{
if(a.rows.length==(getRowIndex()+1)) return;
a.moveRow(getRowIndex(),getRowIndex()+1);
}
function rowMovePre()
{
if(getRowIndex()==1) return;
a.moveRow(getRowIndex(),getRowIndex()-1);
}
function getRowIndex()
{
var r = event.srcElement;
while(r.tagName!="TR") r = r.parentElement;
return r.rowIndex;
}
function returnfalse(){return false;};
function init()
{
appendOptCell();
}
init();
}
document.body.onload = function()
{
document.frm.db_name.selectedIndex = 0;
display_tbl(document.frm.db_name.options[0].value);
}
//-->
</SCRIPT>
<?ljh_system_bottom();?>
[email protected]
什么刷新页面?什么意思?我这里电脑都没有出现什么异常现象啊?这么没人顶啊,大家用不上么?
1.可以对每个表取中文名称,这样文档里面可以通过这个名称看懂表的含义
2.添加了数据库所有表的简介表
3.使用了标题,这样拷贝到WORD里面,可以根据这些标题生成索引目录过两天就上传,谢谢大家关心!
谢了,好东西!