How to remotely create Mysql database with IE _ PHP Tutorial

Source: Internet
Author: User
Use IE to remotely create a simple Mysql database. John recently learned about Mysql databases and compiled a simple program to remotely create Mysql databases using IE. this program is applicable to anyone who knows nothing about Mysql databases, you can easily create a Mysql database. Recently, I learned how to create a simple program to remotely create a Mysql database using IE. this program is applicable to anyone who knows nothing about the Mysql database, you can easily create Mysql databases and tables of various types in the database, and they are completely graphic interfaces. you may not even know a single SQL statement, the program I have compiled may still be very simple. here I only think of the role of the plug-in. I hope you can constantly improve this program and create a Mysql manager with a real graphical interface.
This program is divided into two files:
Mkdb.htm: collects user information for use in the. php file below.


MYSQL database creation ticket











Mkdb. php: use the function to contact mysql.



MYSQL database creation result
Function showdb ($ result)
{
Echo"













"; $ I = 0;While ($ row = mysql_fetch_array ($ result )){$ I = $ I + 1;Echo" ";Echo" ";}}Function showcol ($ result){Echo"
Database No. Database name
$ I";
Echo $ row ["Database"];
Echo"













"; $ I = 0;While ($ row = mysql_fetch_array ($ result )){Echo" ";Echo" ";}}Function showtab ($ result, $ DATABASENAME){Echo"
Field name Field type
";
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"
Table No. Table name
$ I";
Echo $ row ["Tables_in _". $ DATABASENAME];
Echo"
";
Echo "$ dbname created successfully! ";
Echo"
";}
Else {
Echo"
";
Echo "creation failed! ";
Echo"
";}
}
Function dropdb ($ dbname)
{
$ Result = mysql_drop_db ($ dbname );
If ($ result ){
Echo"
";
Echo "$ dbname deleted successfully! ";
Echo"
";}
Else {
Echo"
";
Echo "failed to delete! ";
Echo"
";}
}
?>


The database creation result is as follows:
$ Result = mysql_connect ();
Switch ($ SWCODE ){
Case 'create database ':
Creatdb ($ DATABASENAME );
Echo" The current database list is as follows:
";
$ Result = mysql_list_dbs ();
Showdb ($ result );
Break;
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" $ TABLENAME table already exists in database: $ DATABASENAME. Check table name! ";
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" The $ TABLENAME table is successfully created in database: $ DATABASENAME! ";
$ Result = mysql_db_query ($ DATABASENAME, "show columns from $ TABLENAME ");
Showcol ($ result );
}
Else
{
Echo" An error occurred while creating the $ TABLENAME table in database: $ DATABASENAME! Check the cause! ";
}
}
}
Else
Echo" This database does not exist! Check the database name.
";
$ Result = mysql_db_query ($ DATABASENAME, "show tables ");
If ($ result)
{
Echo" The following table exists in ". $ DATABASENAME: ";
Showtab ($ result, $ DATABASENAME );
}
Break;
Case 'delete table ':
If (mysql_select_db ($ DATABASENAME ))
{
$ Result = mysql_db_query ($ DATABASENAME, "drop table $ TABLENAME ");
If ($ result)
{
Echo" You have successfully deleted the table ". $ TABLENAME." in the database ". $ DATABASENAME .". ";
$ Result = mysql_db_query ($ DATABASENAME, "show tables ");
If ($ result)
{
Echo" The following table exists in ". $ DATABASENAME: ";
Showtab ($ result, $ DATABASENAME );
}
}
Else
{
Echo" The table ". $ TABLENAME." is not deleted in the database ". $ DATABASENAME! ";
$ Result = mysql_db_query ($ DATABASENAME, "show tables ");
If ($ result)
{
Echo" The following table exists in ". $ DATABASENAME: ";
Showtab ($ result, $ DATABASENAME );
}
}
}
Else
Echo" Database ". $ DATABASENAME." does not exist! ";
Break;
Default:
Echo" You did nothing! ";
Break;
}
?>



When used, you need to separate two files to the apache's directory and use iew.mkdb.html.

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.