Case study: micro blog

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.