Project database creation for PHP development article publishing system
Database Analysis
The database of the article publishing system mainly contains an article table. The table should contain a primary key id, article title, article author, and article description. , article details and the publication time of the article. The field details are as follows:
Database creation
We run mysql under the command prompt window (specifically how to connect through the command prompt window Database, you can refer to Section 2.2 in our previous course "PHP Development Login Registration Tutorial")
After successfully connecting to the database, copy the complete statement to create the database below into the window, and press Press Enter to prompt that the creation is successful, as shown below
Complete statement to create the database
DROP DATABASE IF EXISTS articledb; CREATE DATABASE articledb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE articledb; CREATE TABLE article( id int(11) NOT NULL AUTO_INCREMENT, title varchar(30) NOT NULL, author varchar(30) DEFAULT NULL, description text DEFAULT NULL, content text DEFAULT NULL, dateline int(11) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; insert into article(title,author) values('admin','admin');
Statement explanation
First determine whether the articledb database exists, and if it exists, delete it first
Create the articledb database after judgment, encode it in utf8 format
Select the articledb database we created
Create article data table
The table contains 6 fields, of which id is the primary key and grows by itself
Insert a piece of data after creation , which is convenient for us to use later
##Database configuration file information
config.php
Code explanation:
##Connection database information
The connect.php code is as follows
Code explanation:
-
Introduced the database configuration file
- Connecting to the database failed and prompted an error message
- Select the database we just created
- The device encoding format is utf8
- Continuing Learning
||DROP DATABASE IF EXISTS articledb; CREATE DATABASE articledb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE articledb; CREATE TABLE article( id int(11) NOT NULL AUTO_INCREMENT, title varchar(30) NOT NULL, author varchar(30) DEFAULT NULL, description text DEFAULT NULL, content text DEFAULT NULL, dateline int(11) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; insert into article(title,author) values('admin','admin');
- Course Recommendations
- Courseware download
-
IntermediateFront-end Vue3 actual combat [handwritten vue project]
2857 people are watching -
ElementaryAPIPOST tutorial [Popularization of technical concepts related to network communication]
1795 people are watching -
IntermediateIssue 22_Comprehensive actual combat
5521 people are watching -
ElementaryIssue 22_PHP Programming
5172 people are watching -
ElementaryIssue 22_Front-end development
8713 people are watching -
IntermediateBig data (MySQL) video tutorial full version
4525 people are watching -
ElementaryGo language tutorial-full of practical information and no nonsense
2794 people are watching -
ElementaryGO Language Core Programming Course
2814 people are watching -
IntermediateJS advanced and BootStrap learning
2563 people are watching -
IntermediateSQL optimization and troubleshooting (MySQL version)
3374 people are watching -
IntermediateRedis+MySQL database interview tutorial
2963 people are watching -
ElementaryDeliver food or learn programming?
5708 people are watching
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~
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)
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
Field name |
Field type |
Field length |
Field description |
id |
int |
#11 | |
#title |
varchar |
30 | Article title |
author |
varchar |
30 | Article author |
description |
text |
##Article description | |
content | text | ||
int | 11 | Published time |