Principles and Examples: php + mysql + jquery to generate static webpages (including the background editing function)

Source: Internet
Author: User
Principles and Examples: php + mysql + jquery generates static webpages (including background editing functions). according to the working principle of the Web, the server load caused by user access to HTML is much smaller than the access to dynamic pages, in the former, the server only sends the corresponding html code to the client. in the latter, the server needs to perform a series of calculations based on the access conditions and then generate the html code, finally, the calculation result code is sent to the client. Therefore, static pages should be used as much as possible for promotional websites (such as news websites) with large traffic volumes.

On the other hand, we cannot allow website editors to manually create these HTML files one by one, which is a return to the pure static era many years ago. We can use dynamic languages to generate these static webpages conveniently and quickly. Moreover, this technology is very mature. This article starts with the simplest principle and case studies, and tries to understand the general methods and procedures, regardless of the specific details (such as text editor ).

Procedure:

1. create an html page with blank content as a template.

2. when a website editor adds a record to the background, add the record content to the corresponding location of the template file, and save it as an html file in a specific location.

3. record the file information in the database

4. read and display records in the database at the front-end

5. background editing is essentially adding, deleting, and modifying html files. the preceding operations are also performed on records in the database.


Directory structure:


Database design:

Create database cms_php_html;

Use cms_php_html;

Create table if not exists 'newslist '(

'Nid' int (11) not null AUTO_INCREMENT,

'Ntitle' varchar (50) COLLATE utf8_bin not null,

'URL' varchar (100) COLLATE utf8_bin not null,

Primary key ('nid ')

) ENGINE = InnoDB default charset = utf8;


Code:

1. front-end homepage: index.html

 NewsList

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.