帝王谷资源网 Design By www.wdxyy.com
小生近日来学习Mysql数据库,自己编写一个用IE远程创建Mysql数据库的简易程序,此程序适用与对Mysql数据库一无所知的人,可以轻松的创建Mysql数据库及数据库中的各种类型的表,而且完全是图形界面,你甚至可以一句sql语句都不知道,我编写的这个程序可能尚还十分简陋,在此我只想起一个抛砖引玉的作用,希望大家能不断完善此程序,做一个真正意义上的图形界面的Mysql管理器.
此程序共分两个文件:
mkdb.htm:搜集使用者信息,给下面的.php文件使用.
<HTML>
<HEAD>
<TITLE>MYSQL数据库创建单</TITLE>
</HEAD>
<BODY>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>创建一个新的数据库</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=创建数据库 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>删除一个已有的数据库</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=删除数据库 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=500 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>在一个已有的数据库中创建表</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=350>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入表名:</TD>
<TD WIDTH=350>
<INPUT TYPE=TEST SIZE=30 VALUE=TESTABLE NAME=TABLENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<TABLE WIDTH=500 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 VALUE=IDX NAME=FIELDNAME[1]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[1] SIZE=1>
<OPTION VALUE=INTEGER(10) SELECTED>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[2]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[2] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[3]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[3] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[4]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[4] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[5]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[5] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[6]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[6] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[7]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[7] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[8]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[8] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[9]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[9] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[10]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[10] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=创建表 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>删除一张已有的表</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入表格名称:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=TESTABLE NAME=TABLENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=删除表 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
mkdb.php:通过函数联系mysql.
<HTML>
<HEAD>
<TITLE>MYSQL数据库创建结果</TITLE>
<?php
function showdb($result)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>数据库序号</TD>
<TD WIDTH=250 ALIGN=CENTER>数据库名</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
$i=$i+1;
echo "<TR><TD WIDTH=100 ALIGN=CENTER>$i</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Database"];
echo "</TD></TR></CENTER>";
}
}
function showcol($result)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>字段名</TD>
<TD WIDTH=250 ALIGN=CENTER>字段类型</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
echo "<TR><TD WIDTH=100 ALIGN=CENTER>";
echo $row["Field"];
echo "</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Type"];
echo "</TD></TR></CENTER>";
}
}
function showtab($result,$DATABASENAME)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>表格序号</TD>
<TD WIDTH=250 ALIGN=CENTER>表格名称</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
$i=$i+1;
echo "<TR><TD WIDTH=100 ALIGN=CENTER>$i</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Tables_in_".$DATABASENAME];
echo "</TD></TR></CENTER>";
}
}
function creatdb($dbname)
{
$result=mysql_create_db($dbname);
if ($result){
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>$dbname 创建成功!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
else{
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>创建失败!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
}
function dropdb($dbname)
{
$result=mysql_drop_db($dbname);
if ($result){
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>$dbname 成功删除!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
else{
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>删除失败!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
}
?>
</HEAD>
<BODY>
<CENTER><H3>数据库创建结果如下:</H3></CENTER>
<?php
$result=mysql_connect();
switch($SWCODE){
case '创建数据库':
creatdb($DATABASENAME);
echo "<CENTER><H4>目前数据库列表如下:</H4></BR></CENTER>";
$result=mysql_list_dbs();
showdb($result);
break;
case '删除数据库':
dropdb($DATABASENAME);
echo "<CENTER><H4>目前数据库列表如下:</H4></BR></CENTER>";
$result=mysql_list_dbs();
showdb($result);
break;
case '创建表':
if (mysql_select_db($DATABASENAME))
{
if (mysql_db_query($DATABASENAME,"select * from $TABLENAME"))
echo "<H4><CENTER>在数据库: $DATABASENAME 中已存在 $TABLENAME 表。请检查表名称!</CENTER></H4>";
else
{
$string="CREATE TABLE ".$TABLENAME."(";
if ($TYPE[1]<>"NONE") $string=$string.$FIELDNAME[1]." ".$TYPE[1];
for($i=2;$i<=10;$i++)
{
if ($TYPE[$i]<>"NONE") $string=$string.",".$FIELDNAME[$i]." ".$TYPE[$i];
}
$string=$string.")";
$result=mysql_db_query($DATABASENAME,"$string");
if ($result)
{
echo "<H4><CENTER>成功的在数据库: $DATABASENAME 中创建 $TABLENAME 表!</CENTER></H4>";
$result=mysql_db_query($DATABASENAME,"SHOW COLUMNS FROM $TABLENAME");
showcol($result);
}
else
{
echo "<H4><CENTER>在数据库: $DATABASENAME 中创建 $TABLENAME 表的动作失败!请检查原因!</CENTER></H4>";
}
}
}
else
echo "<CENTER><H4>此数据库不存在!请检查数据库名。</H4></BR></CENTER>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
break;
case '删除表':
if (mysql_select_db($DATABASENAME))
{
$result=mysql_db_query($DATABASENAME,"DROP TABLE $TABLENAME");
if ($result)
{
echo "<CENTER><H3>已成功的在数据库".$DATABASENAME."中将表".$TABLENAME."删除</CENTER></H3>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
}
else
{
echo "<CENTER><H3>在数据库".$DATABASENAME."中未将表".$TABLENAME."删除!</CENTER></H3>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
}
}
else
echo "<CENTER><H3>数据库".$DATABASENAME."不存在!</H3></CENTER>";
break;
default:
echo "<center><h2>你什么事都没干!</h2></center>";
break;
}
?>
</BODY>
</HTML>
使用时,需将着两个文件分别放到Apache的访问目录下,并用IE访问mkdb.html便可.
此程序共分两个文件:
mkdb.htm:搜集使用者信息,给下面的.php文件使用.
<HTML>
<HEAD>
<TITLE>MYSQL数据库创建单</TITLE>
</HEAD>
<BODY>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>创建一个新的数据库</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=创建数据库 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>删除一个已有的数据库</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=删除数据库 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=500 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>在一个已有的数据库中创建表</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=350>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入表名:</TD>
<TD WIDTH=350>
<INPUT TYPE=TEST SIZE=30 VALUE=TESTABLE NAME=TABLENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<TABLE WIDTH=500 BORDER=1 cellspacing=0 cellpadding=0>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 VALUE=IDX NAME=FIELDNAME[1]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[1] SIZE=1>
<OPTION VALUE=INTEGER(10) SELECTED>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[2]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[2] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[3]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[3] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[4]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[4] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[5]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[5] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[6]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[6] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[7]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[7] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[8]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[8] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[9]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[9] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH=75 ALIGN=CENTER>字段名</TD>
<TD WIDTH=175 ALIGN=CENTER><INPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[10]></TD>
<TD WIDTH=75 ALIGN=CENTER>字段类型</TD>
<TD WIDTH=175 ALIGN=CENTER>
<SELECT NAME=TYPE[10] SIZE=1>
<OPTION VALUE=INTEGER(10)>普通整型</OPTION>
<OPTION VALUE=TINYINT(3)>短整型</OPTION>
<OPTION VALUE=FLOAT(10,4)>单精度浮点型</OPTION>
<OPTION VALUE=DOUBLE(10,4)>双精度浮点型</OPTION>
<OPTION VALUE=DATE>日期型</OPTION>
<OPTION VALUE=VARCHAR(255)>可变字符型</OPTION>
<OPTION VALUE=CHAR(20)>字符型(20个字符)</OPTION>
<OPTION VALUE=NONE SELECTED>空字段</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=创建表 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
<FORM METHOD="POST" ACTION="MKDB.PHP">
<TABLE WIDTH=400 BORDER=1 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN=CENTER COLSPAN=2>删除一张已有的表</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入数据库名:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=DATABASE NAME=DATABASENAME>
</TD>
</TR>
<TR>
<TD WIDTH=150 ALIGN=CENTER>请输入表格名称:</TD>
<TD WIDTH=250 ALIGN=CENTER>
<INPUT TYPE=TEST SIZE=30 VALUE=TESTABLE NAME=TABLENAME>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE=删除表 NAME=SWCODE>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
mkdb.php:通过函数联系mysql.
<HTML>
<HEAD>
<TITLE>MYSQL数据库创建结果</TITLE>
<?php
function showdb($result)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>数据库序号</TD>
<TD WIDTH=250 ALIGN=CENTER>数据库名</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
$i=$i+1;
echo "<TR><TD WIDTH=100 ALIGN=CENTER>$i</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Database"];
echo "</TD></TR></CENTER>";
}
}
function showcol($result)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>字段名</TD>
<TD WIDTH=250 ALIGN=CENTER>字段类型</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
echo "<TR><TD WIDTH=100 ALIGN=CENTER>";
echo $row["Field"];
echo "</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Type"];
echo "</TD></TR></CENTER>";
}
}
function showtab($result,$DATABASENAME)
{
echo "<CENTER><TABLE BORDER=1 WIDTH=350 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=100 ALIGN=CENTER>表格序号</TD>
<TD WIDTH=250 ALIGN=CENTER>表格名称</TD>
</TR>";$i=0;
while($row=mysql_fetch_array($result))
{
$i=$i+1;
echo "<TR><TD WIDTH=100 ALIGN=CENTER>$i</TD>";
echo "<TD WIDTH=250 ALIGN=CENTER>";
echo $row["Tables_in_".$DATABASENAME];
echo "</TD></TR></CENTER>";
}
}
function creatdb($dbname)
{
$result=mysql_create_db($dbname);
if ($result){
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>$dbname 创建成功!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
else{
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>创建失败!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
}
function dropdb($dbname)
{
$result=mysql_drop_db($dbname);
if ($result){
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>$dbname 成功删除!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
else{
echo "<CENTER><TABLE BORDER=0 WIDTH=350 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER>";
echo "<H4>删除失败!</H4>";
echo "</TD></TR></TABLE></CENTER>";}
}
?>
</HEAD>
<BODY>
<CENTER><H3>数据库创建结果如下:</H3></CENTER>
<?php
$result=mysql_connect();
switch($SWCODE){
case '创建数据库':
creatdb($DATABASENAME);
echo "<CENTER><H4>目前数据库列表如下:</H4></BR></CENTER>";
$result=mysql_list_dbs();
showdb($result);
break;
case '删除数据库':
dropdb($DATABASENAME);
echo "<CENTER><H4>目前数据库列表如下:</H4></BR></CENTER>";
$result=mysql_list_dbs();
showdb($result);
break;
case '创建表':
if (mysql_select_db($DATABASENAME))
{
if (mysql_db_query($DATABASENAME,"select * from $TABLENAME"))
echo "<H4><CENTER>在数据库: $DATABASENAME 中已存在 $TABLENAME 表。请检查表名称!</CENTER></H4>";
else
{
$string="CREATE TABLE ".$TABLENAME."(";
if ($TYPE[1]<>"NONE") $string=$string.$FIELDNAME[1]." ".$TYPE[1];
for($i=2;$i<=10;$i++)
{
if ($TYPE[$i]<>"NONE") $string=$string.",".$FIELDNAME[$i]." ".$TYPE[$i];
}
$string=$string.")";
$result=mysql_db_query($DATABASENAME,"$string");
if ($result)
{
echo "<H4><CENTER>成功的在数据库: $DATABASENAME 中创建 $TABLENAME 表!</CENTER></H4>";
$result=mysql_db_query($DATABASENAME,"SHOW COLUMNS FROM $TABLENAME");
showcol($result);
}
else
{
echo "<H4><CENTER>在数据库: $DATABASENAME 中创建 $TABLENAME 表的动作失败!请检查原因!</CENTER></H4>";
}
}
}
else
echo "<CENTER><H4>此数据库不存在!请检查数据库名。</H4></BR></CENTER>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
break;
case '删除表':
if (mysql_select_db($DATABASENAME))
{
$result=mysql_db_query($DATABASENAME,"DROP TABLE $TABLENAME");
if ($result)
{
echo "<CENTER><H3>已成功的在数据库".$DATABASENAME."中将表".$TABLENAME."删除</CENTER></H3>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
}
else
{
echo "<CENTER><H3>在数据库".$DATABASENAME."中未将表".$TABLENAME."删除!</CENTER></H3>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
{
echo "<CENTER><H5>在".$DATABASENAME."中已存在的表格如下所示:</H5></CENTER>";
showtab($result,$DATABASENAME);
}
}
}
else
echo "<CENTER><H3>数据库".$DATABASENAME."不存在!</H3></CENTER>";
break;
default:
echo "<center><h2>你什么事都没干!</h2></center>";
break;
}
?>
</BODY>
</HTML>
使用时,需将着两个文件分别放到Apache的访问目录下,并用IE访问mkdb.html便可.
帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com
暂无评论...
更新日志
2024年12月30日
2024年12月30日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]