# Elementary case description
Source code download
1. The structure is as follows
conn.php is the connection database file
index.php is the homepage and the blog list page select * from weibo where $id order by id desc limit 10;
edit. php is the edit page UPDATE weibo SET `title`='$title',`contents`='$contents' where `id`='$hid'
del.php is the delete operation page
add.php is the add page
view .php is the details page
2. Database
Field description id, hit clicks, title, dates, contents
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;
3. Notes:
1. When editing, use a hidden field in the form to pass the id
2. Use where $w cleverly when searching,
if(!empty($_GET[' keys'])){
// $w = `title` like $_GET['keys'];
$w = " `title` like '%" . $_GET ['keys'] . "%' "; //Use fuzzy search
}else{
$w = 1; //This code has no practical meaning when converted into sql statement.
// sql statement is select * from `weibo` where 1 order by id desc limit 10;
}
If you don’t understand, please leave a message (WeChat: moka_2024)
The above introduces a small case: micro blog, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.