亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Database and form creation in PHP development

First create a CREATE DATABASE database in the database using the database creation statement. The name is regedit:

<?php
// 創(chuàng)建連接
$conn = new mysqli("localhost", "root", "root");
// 檢測(cè)連接
if ($conn->connect_error) 
{    
    die("連接失敗: " . $conn->connect_error);} 
    // 創(chuàng)建數(shù)據(jù)庫
    $sql = "CREATE DATABASE regedit";
        if ($conn->query($sql) === TRUE) 
        {    
        echo "數(shù)據(jù)庫創(chuàng)建成功";
        } else {    
        echo "Error creating database: " . $conn->error;
        }
    $conn->close();
?>

In this way, the database is created. Next, we create a form called form in the regedit library. The form contains information as follows:

Table name: form

##Field nameidusernamepasswordField typeintvarcharvarcharField length5100100Field description User idUsernameUser passwordBased on the information in the table, we create the table and use the table creation statement:

<?php
// 創(chuàng)建連接
$conn = new mysqli("localhost", "root", "root","regedit");
// 檢測(cè)連接
if ($conn->connect_error) 
{    
die("連接失敗: " . $conn->connect_error);
} 
// 使用 sql 創(chuàng)建數(shù)據(jù)表
$sql = "CREATE TABLE form (
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL,
password VARCHAR(30) NOT NULL,)ENGINE=InnoDB DEFAULT CHARSET=utf8 ";
if ($conn->query($sql) === TRUE) 
{    
echo "Table MyGuests created successfully";
} else {    
echo "創(chuàng)建數(shù)據(jù)表錯(cuò)誤: " . $conn->error;
}
$conn->close(); 
?>

In this way, the database is built, the data table is also built, and the rest can be added.

Of course, we can also use another method to add, which will be faster.

Take phpStudy as an example:

1I`05H5O_6~S50G]%I99[4H.png

Click the button, select phpMyStudy, enter the database login page, and the account and password are both root.

Then enter this page and click "Database", as shown in the picture:

}[HE0[@CYK[$`ZQ(ZNFU6[F.png

Then when you get to this page, you can fill in the name of the database where the arrow points. , click Create, and it is created.

0DHDHR3(~C6F``S35CFQH5J.png


Next, you can create the data table, name the table, and number of fields. After creating it, there will be an execution in the lower right corner. Click to create the form.

VBL)D`703M3LYF}26GPGF.png

Continuing Learning
||
<?php // 創(chuàng)建連接 $conn = new mysqli("localhost", "root", "root"); // 檢測(cè)連接 if ($conn->connect_error) { die("連接失敗: " . $conn->connect_error);} // 創(chuàng)建數(shù)據(jù)庫 $sql = "CREATE DATABASE regeit"; if ($conn->query($sql) === TRUE) { echo "數(shù)據(jù)庫創(chuàng)建成功"; } else { echo "Error creating database: " . $conn->error; } $conn->close(); ?>
submitReset Code