PHP develops simple voting system to create database and table
First create a database "test" in mysql
connect_error) { die("连接失败: " . $conn->connect_error);} // 创建数据库 $sql = "CREATE DATABASE test"; if ($conn->query($sql) === TRUE) { echo "数据库创建成功"; } else { echo "Error creating database: " . $conn->error; } $conn->close(); ?>
Then we need to create a voto table to add voting items
Settings The following fields:
#id: It is unique, type is int, and the primary key is selected.
titleid: fixed, type is int
item: voting item, type is varchar, length is 50.
count: Number of votes, type is int.
Add some test content, such as
and then create another table votetitle to store the title.
Set the following fields:
titleid: type is int
votetitle: title, type is varchar, length is 50.
Add a title statement:
In this way, we have created the database and tables, and added some test data.