p; <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($DATABA
<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($DATABA