Getting Started with PHP - Creating a New Database
For the database, we have two ways to create it. One is to use code to create it.
The code is as follows:
create database
Note: $con is to link the database $ info To execute the sql statement
Run this code, and then check the database. If the database already exists, it cannot be created
The second is to enter the URL http://localhost /phpMyAdmin/
Then enter the user and password to create the database on a simple page
to the database Delete operation
You can enter the database and delete the table visually. The visualization will be more intuitive
Use code to delete, the code is as follows:
DROP DATABASE Delete the database
drop database
Run the code, and then check the database to see if the database has been deleted
Create mysql data table
You can create a table visually or code. The code is as follows:
创建 MySQL 数据表 '; $sql = "CREATE TABLE php_tbl( ". "php_id INT NOT NULL AUTO_INCREMENT, ". "php_title VARCHAR(100) NOT NULL, ". "php_author VARCHAR(40) NOT NULL, ". "submission_date DATE, ". "PRIMARY KEY ( php_id )); "; mysql_select_db( 'php' ); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('数据表创建失败: ' . mysql_error()); } echo "数据表创建成功\n"; mysql_close($conn); ?>
Delete data table
Visual operation is a convenient way. You can also use a script to delete the code as follows:
删除 MySQL 数据表 '; $sql = "DROP TABLE php_tbl"; mysql_select_db( 'php' ); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('数据表删除失败: ' . mysql_error()); } echo "数据表删除成功\n"; mysql_close($conn); ?>
Note: Due to server security considerations, database-related codes are not available online. For testing, you can copy the code and test it locally on your computer