您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
用IE远程创建Mysql数据库的简易程序
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:36:17
SENAME);
        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便可.

上一页  [1] [2] [3] [4] 


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |