Small Case: Micro Blog

Source: Internet
Author: User
# Primary Case Description

SOURCE download

First, the structure is as follows

conn.php to connect to the database file

index.php first page, also the blog list page select * from Weibo where $id order by id desc limit 10;

edit.php for edit page UPDATE Weibo SET ' title ' = ' $title ', ' contents ' = ' $contents ' where ' id ' = ' $hid '

del.php The Delete action page

add.php for adding pages

view.php for details page

Second, the database

Field Description ID, hit volume, title title, dates date, contents content

CREATE TABLE ' Weibo ' (

' ID ' int (5) not NULL auto_increment,

' Hit ' int (one) is not NULL,

' title ' varchar (not NULL),

' Dates ' date not NULL,

' Contents ' text is not NULL,

PRIMARY KEY (' id ')

) Engine=myisam auto_increment=6 DEFAULT Charset=utf8;

Third, the attention point:

1. When editing, use a hidden field in the form to pass the ID

2. The where $w is used skillfully when searching,

if (!empty ($_get[' Keys ')) {

$w = ' title ' Like $_get[' keys ';

$w = "' title ' Like '% '. $_get [' Keys ']. "%' "; Using Fuzzy search

}else{

$w = 1; There is no practical meaning in translating this sentence code into an SQL statement.

The SQL statement is select * from ' Weibo ' where 1 order by id DESC limit 10;

}

Do not understand please leave a message (: moka_2024)

The above describes the small case: micro-blog, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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