Small case: micro-blog; Case: micro-blog
# 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)