国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>create database</title>
</head>
<body>
	<?php
		$con = mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫(kù)連接失敗");
		$sql ="CREATE DATABASE test1";
		$info = mysql_query($sql);
		if($info){
			echo "創(chuàng)建成功";
		}else{
			echo "創(chuàng)建失敗";
		}
	?>
</body>
</html>

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

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>drop database</title>
</head>
<body>
	<?php
		$con = mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫(kù)連接失敗");

		$sql ="DROP DATABASE test1";

		$info = mysql_query($sql);

		if($info){
			echo "刪除成功";
		}else{
			echo "刪除失敗";
		}
	?>
</body>
</html>

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:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>創(chuàng)建 MySQL 數(shù)據(jù)表</title>
</head>
<body>
<?php
	$dbhost = 'localhost';
	$dbuser = 'root';
	$dbpass = 'root';
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	if(! $conn )
	{
	  die('連接失敗: ' . mysql_error());
	}
	echo '連接成功<br />';
	$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('數(shù)據(jù)表創(chuàng)建失敗: ' . mysql_error());
	}
	echo "數(shù)據(jù)表創(chuàng)建成功\n";
	mysql_close($conn);
?>
</body>
</html>

Delete data table

Visual operation is a convenient way. You can also use a script to delete the code as follows:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>刪除 MySQL 數(shù)據(jù)表</title>
</head>
<body>
	<?php
		$dbhost = 'localhost';
		$dbuser = 'root';
		$dbpass = 'root';
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		if(! $conn )
		{
		  die('連接失敗: ' . mysql_error());
		}
		echo '連接成功<br />';
		$sql = "DROP TABLE php_tbl";
		mysql_select_db( 'php' );
		$retval = mysql_query( $sql, $conn );
		if(! $retval )
		{
		  die('數(shù)據(jù)表刪除失敗: ' . mysql_error());
		}
		echo "數(shù)據(jù)表刪除成功\n";
		mysql_close($conn);
	?>
</body>
</html>

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

Continuing Learning
||
<?php echo "歡迎學(xué)習(xí)數(shù)據(jù)庫(kù)知識(shí)"; ?>
submitReset Code