Home  >  Article  >  Backend Development  >  A simple program to remotely create a Mysql database using IE_PHP tutorial

A simple program to remotely create a Mysql database using IE_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:09:421081browse

Xiaosheng recently came to learn Mysql database and wrote a simple program to remotely create Mysql database using IE. This program is suitable for people who know nothing about Mysql database. It can easily create Mysql database and various types of tables in the database. And it’s a completely graphical interface. You can’t even know a single SQL statement. The program I wrote may still be very crude. I just think of it as a way to attract new ideas. I hope everyone can continue to improve this program and make it a real program. Mysql manager with a graphical interface.
This program is divided into two files:
mkdb.htm: Collect user information and use it for the following .php file.

< ;HEAD>
MYSQL database creation form








ALIGN=CENTER>
                                                            lt ;TD ALIGN=CENTER COLSPAN=2>


Create a new database< /TD>
Please enter the database name:





=150 ALIGN=CENTER>Please enter the database name:





Delete an existing database

  

;
      














                                                                                          ;
                    20 NAME=FIELDNAME [3]>
                                   
                                                                                                                                                < >Single-precision floating point type
                                                                                                                                                                                                                   
          ;/OPTION>
                                                                            
TR & gt;
& lt; td width = 75 align = center & gt; field name & lt;/td & gt;
& lt; td width = 175 align = center & lt; " St size = 20 name = fieldname [5 ]> lt;SELECT NAME=TYPE [5] SIZE=1> ;
            
                                                                              /OPTION>


                                                           ;OPTION VALUE=NONE SELECTED>Empty field
                                           lt;TR>
                                                    TD WIDTH=75 ALIGN=CENTER>Field name
& lt; td width = 75 align = center & gt; field type & lt;/td & gt;
& lt; td width = 175 align = center & gt;
& lt; select name = type [6] Size = 1 & gt;
                                                                                                                    TION VALUE =FLOAT(10,4)>Single-precision floating-point type
    
   < OPTION VALUE=DATE>Date type
                                     < Type (20 characters)
                                                                             🎜>                                          /TR>
                                                                     UT TYPE=TEST SIZE =20 NAME=FIELDNAME[7]> >                                                                                                                 ; Short integer & lt;/option & gt;
& lt; option value = float (10,4) & gt; single precision floating -point & lt;/option & gt;
& lt; option value = dough (10,4) & gt; Double precision floating point type
                 

                                             
                                        ;TD WIDTH=75 ALIGN=CENTER>Field name
      
                                                                         " 3)> ; Short integer & lt;/option & gt;
& lt; option value = flow (10,4) & gt; single precision floating -point & lt;/option & gt;
& lt; option value (10,4) & gt. ;Double precision floating point type ;
                                                                ​< /SELECT>
                                                                             [ 10]>
Create in an existing database Table
Please enter the database name:
                                                             lt ;TD WIDTH=150 ALIGN=CENTER>Please enter the table name:

>

=0>
                                                                     UT TYPE=TEST SIZE =20 VALUE=IDX NAME=FIELDNAME[1]>

                                                                      ​ =75 ALIGN=CENTER>Field type
& Lt; td width = 75 align = center & gt; field type & lt;/td & gt;
& lt; td width = 175 align = center & gt;
& lt; selct name = type [ 8] size = 1 & gt;
                                                                                                                             TION VALUE=FLOAT(10,4)>Single precision floating point type
                                                                          ;OPTION VALUE=DATE>Date type
                                                                                     < Character type (20 characters)
                                                     ;
       < ;/TR>
 ​                                                                        NPUT TYPE=TEST SIZE=20 NAME=FIELDNAME[9]>





                                                                                                         ;/TD>




  ";$i=0;
    while($row=mysql_fetch_array($result))
    {
        $i=$i+1;
        echo "";
        echo "";
    }
}
function showcol($result)
{
    echo "
Delete an existing table
Please enter the database name:
Please enter the table name:
                                                           ;






mkdb.php: Contact mysql through functions.



MYSQL database creation result
function showdb($result)
{ Echo "& lt; center & gt; & lt; table border = 1 width = 350 cellspacing = 0 cellpadding = 0 & gt;
& lt;
& lt; td width = 100 alig N = center & gt; database serial number & lt;/td & gt ;
Database name
$i";
        echo $row["Database"];
        echo "

    
        
        
    ";$i=0;
    while($row=mysql_fetch_array($result))
    {
        echo "";
        echo "";
    }
}
function showtab($result,$DATABASENAME)
{
    echo "
字段名 字段类型
";
        echo $row["Field"];
        echo "
";
        echo $row["Type"];
        echo "

    
        
        
    ";$i=0;
    while($row=mysql_fetch_array($result))
    {
        $i=$i+1;
        echo "";
        echo "";
    }
}
function creatdb($dbname)
{
    $result=mysql_create_db($dbname);
    if ($result){
        echo "
表格序号 表格名称
$i";
        echo $row["Tables_in_".$DATABASENAME];
        echo "
";
        echo "

$dbname 创建成功!

";
        echo "
";}
    else{
        echo "
";
        echo "

创建失败!

";
        echo "
";}
}
function dropdb($dbname)
{
    $result=mysql_drop_db($dbname);
    if ($result){
        echo "
";
        echo "

$dbname 成功删除!

";
        echo "
";}
else{
echo "
";
echo "< H4>Delete failed!";
  echo "
";}
}
?>


The database creation results are as follows:


$result=mysql_connect();
switch($SWCODE){
case 'Create database':
creatdb($DATABASENAME);
echo "

Current database The list is as follows: & lt;/h4 & gt; & lt;/br & gt; & lt;/center & gt; "
$ result = mysql_dbs ();
showdb ($ result); Case' delete Database':
dropdb($DATABASENAME);
echo "

The current database list is as follows:


";
$result=mysql_list_dbs();
showdb($result);
break;
case 'Create table':
if (mysql_select_db($DATABASENAME))
{
if ( mysql_db_query($DATABASENAME,"select * from $TABLENAME"))
       echo "

The $TABLENAME table already exists in the database: $DATABASENAME.请检查表名称!

";
            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  "

成功的在数据库: $DATABASENAME 中创建 $TABLENAME 表!

";
                    $result=mysql_db_query($DATABASENAME,"SHOW COLUMNS FROM $TABLENAME");
                    showcol($result);
                }
                else
                {
                    echo "

在数据库: $DATABASENAME 中创建 $TABLENAME 表的动作失败!请检查原因!

";
                }
            }
        }
        else
            echo "

此数据库不存在!请检查数据库名。


";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES"); echo "
The existing table in ".$DATABASENAME." is as follows:
";
showtab($result,$DATABASENAME);
                                                                                                       sql_db_query($DATABASENAME,"DROP TABLE $TABLENAME") if ($ result)
{
echo "& lt; center & gt; & lt; h3 & gt; successful in the database". $ Databasename. "Lieutenant Table". CENTER>";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES"); >                                                                                                                                                     ;The existing table in ".$DATABASENAME." is as follows:
";         }
         else
                                                                                                                                                                                                                                                       ";
$result=mysql_db_query($DATABASENAME,"SHOW TABLES");
if ($result)
                                                                                                                   {
The existing table in ".$DATABASENAME." is as follows:
"; 🎜 >     }
   }
   else
      echo "

Database ".$DATABASENAME." does not exist!

";
                 break; center>";
break;
}
?>



When using, you need to connect two files Place them in the access directory of Apache respectively, and use IE to access mkdb.html.


http://www.bkjia.com/PHPjc/314387.html

truehttp: //www.bkjia.com/PHPjc/314387.htmlTechArticleXiaosheng recently came to learn Mysql database and wrote a simple program to create a Mysql database remotely using IE. This program is suitable for People who know nothing about Mysql database can easily create Mysql data...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn