PHP development student management system database creation
Let’s first take a look at the fields to be stored in our database

We will store the information in the above picture into the database
Name
ageage
gender sex
Class class
Now that we know the fields to be stored, let’s create our database first
Create database
<?php
header("Content-type:text/html;charset=utf-8"); //设置编码
$servername = "localhost";
$username = "root";
$password = "root";
// 创建连接
$conn = mysqli_connect($servername, $username, $password);
mysqli_set_charset($conn,'utf8'); //设定字符集
// 检测连接
if (!$conn) {
die("连接失败: " . mysqli_connect_error());
}
// 创建数据库
$sql = "CREATE DATABASE study";
if (mysqli_query($conn, $sql)) {
echo "数据库创建成功";
} else {
echo "数据库创建失败: " . mysqli_error($conn);
}
mysqli_close($conn);
?>The above code creates a database named "study"
Create data table
A 'stu' table was created in the "study" database
| id | name | age | sex | class | |
| INT | VARCHAR | ||||
| 6 | 50 | 6 | 20 | 50 | |
| Student id | Student name | Student age | Student’s gender | Student’s Class |
<?php
header("Content-type:text/html;charset=utf-8"); //设置编码
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "study";
// 创建连接
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_set_charset($conn,'utf8'); //设定字符集
// 检测连接
if (!$conn) {
die("连接失败: " . mysqli_connect_error());
}
// 使用 sql 创建数据表
$sql = "CREATE TABLE stu (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT(6) NOT NULL,
sex VARCHAR(20),
class VARCHAR (50) NOT NULL
);";
if (mysqli_query($conn, $sql)) {
echo "数据表 stu 创建成功";
} else {
echo "创建数据表错误: " . mysqli_error($conn);
}
mysqli_close($conn);
?>We have already created the database, below The first step is to create our HTML page
new file
<?php
header("Content-type:text/html;charset=utf-8"); //设置编码
$servername = "localhost";
$username = "root";
$password = "root";
// 创建连接
$conn = mysqli_connect($servername, $username, $password);
mysqli_set_charset($conn,'utf8'); //设定字符集
// 检测连接
if (!$conn) {
die("连接失败: " . mysqli_connect_error());
}
// 创建数据库
$sql = "CREATE DATABASE study";
if (mysqli_query($conn, $sql)) {
echo "数据库创建成功";
} else {
echo "数据库创建失败: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
Preview
Clear
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~ 