: This article mainly introduces a small case: micro-blog. if you are interested in the PHP Tutorial, refer to it. # Preliminary case description
Source code download
I. The structure is as follows:
Conn. php is the database connection file
Index. php is the homepage and also the blog list page select * from weibo where $ id order by id desc limit 10;
Edit. php UPDATE weibo SET 'title' = '$ title', 'Contents' =' $ contents' where 'id' = '$ hid' for the editing page'
Del. php indicates the delete operation page.
Add. php: add page
View. php is the details page
II. Database
Field description id, hit clicks, title, dates Date, contents content
Create table 'Weibo '(
'Id' int (5) not null AUTO_INCREMENT,
'Hit' int (11) not null,
'Title' varchar (50) not null,
'Dates' date not null,
'Contents' text not null,
Primary key ('id ')
) ENGINE = MyISAM AUTO_INCREMENT = 6 default charset = utf8;
III. notes:
1. during editing, a hidden field is used in the form to pass the id.
2. when searching, where $ w is cleverly used,
If (! Empty ($ _ GET ['Keys ']) {
// $ W = 'title' like $ _ GET ['Keys '];
$ W = "'title' like '%". $ _ GET ['Keys']. "% '"; // use fuzzy search
} Else {
$ W = 1; // it is meaningless to convert the code to an SQL statement.
// The SQL statement is select * from 'Weibo 'where 1 order by id desc limit 10;
}
Leave a message (moka_2024)
The above is a small case: micro blog, including some content, hope to be helpful to friends who are interested in PHP tutorials.