Home > Backend Development > PHP Tutorial > Small case: micro blog

Small case: micro blog

WBOY
Release: 2016-07-29 08:56:02
Original
949 people have browsed it

# 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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template