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

PHP develops a simple book lending system to create database and user table

First we create a database about books, named book.

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

Create a table in the database that needs to be used for user registration and login, named user

Set the following fields:

id: It is unique, type is int, and select the primary key.

name: User name, type is varchar, length is 100.

password: Password, type is varchar, length is 100.

email: Email, type is varchar, length is 100.

tel: Telephone, type is varchar, length is 100.

address: Address, type is varchar, length is 200.

<?php
$SQL = " CREATE TABLE IF NOT EXISTS `user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) DEFAULT NULL,
  `password` varchar(100) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `tel` varchar(100) DEFAULT NULL,
  `address` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ";
?>

Of course you can also create it directly in phpMyAdmin.

Write the created database table into the config.php file so that we can call the database table on different pages in the future.

<?php

ob_start();
session_start(); //開啟緩存
header("Content-type:text/html;charset=utf-8");

$link = mysqli_connect('localhost','root','root','book');
mysqli_set_charset($link, "utf8");
if (!$link) {
  die("連接失敗:".mysqli_connect_error());
}
?>


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