Simple program to create MySQL database remotely with IE

Source: Internet
Author: User
Keywords Simple program to create MySQL database remotely with IE
Tags types of tables
Niche recently to learn MySQL database, and write a simple program to create a MySQL database remotely with IE, this program is suitable for people who know nothing about MySQL database, can easily create MySQL database and database of various types of tables, and is completely graphical interface, You can even an SQL statement do not know, I wrote this program may still be very humble, here I only think of a role, I hope you can constantly improve this program, do a real sense of the GUI of the MySQL manager.
This program is divided into two files:
Mkdb.htm: Collect user information and use it for the following. php files.


<title>MySQL Database Creation order</title>











mkdb.php: Contact MySQL via the function.



<title>MySQL Database creation results</title>
function showdb ($result)
{
echo "













                "; $i = 0;     while ($row =mysql_fetch_array ($result)) {$i = $i +1; echo " "; echo " "; }} function Showcol ($result) {echo '
Database ordinalDatabase name
$i";
echo $row ["Database"];
echo "













                "; $i = 0; while ($row =mysql_fetch_array ($result)) {echo " "; echo " "; }} function ShowTab ($result, $DATABASENAME) {echo '
Field nameField 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 numberTable 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 successfully deleted!

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

Delete failed!

";
echo "
";}
}
?>


The database creation results are as follows:


$result =mysql_connect ();
Switch ($SWCODE) {
Case ' CREATE database ':
Creatdb ($DATABASENAME);
echo "

The current list of databases is as follows:


";
$result =mysql_list_dbs ();
SHOWDB ($result);
Break
Case ' Delete database ':
Dropdb ($DATABASENAME);
echo "

The current list of databases 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 the database: $DATABASENAME. Please check the 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 "

Successfully created $TABLENAME table in database: $DATABASENAME!

";
$result =mysql_db_query ($DATABASENAME, "SHOW COLUMNS from $TABLENAME");
Showcol ($result);
}
Else
{
echo "

The action to create $TABLENAME table in database: $DATABASENAME failed! Please check the cause!

";
}
}
}
Else
echo "

This database does not exist! Please check the database name.


";
$result =mysql_db_query ($DATABASENAME, "SHOW TABLES");
if ($result)
{
echo "

In the ". $DATABASENAME." The tables that already exist are as follows:

";
ShowTab ($result, $DATABASENAME);
}
Break
Case ' Delete table ':
if (mysql_select_db ($DATABASENAME))
{
$result =mysql_db_query ($DATABASENAME, "DROP TABLE $TABLENAME");
if ($result)
{
echo "

Successfully in database ". $DATABASENAME." The table ". $TABLENAME." Delete

";
$result =mysql_db_query ($DATABASENAME, "SHOW TABLES");
if ($result)
{
echo "

In the ". $DATABASENAME." The tables that already exist are as follows:

";
ShowTab ($result, $DATABASENAME);
}
}
Else
{
echo "

In the database ". $DATABASENAME." The table ". $TABLENAME." is not in the Delete!

";
$result =mysql_db_query ($DATABASENAME, "SHOW TABLES");
if ($result)
{
echo "

In the ". $DATABASENAME." The tables that already exist are as follows:

";
ShowTab ($result, $DATABASENAME);
}
}
}
Else
echo "

Database ". $DATABASENAME." does not exist!

";
Break
Default
echo "

You didn't do anything!

";
Break
}
?>



When using, you need to put two files in the Apache Access directory, and use IE to access the 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.