When installing a website in PHP, the front-end dynamically displays the table created by the database. How is the result achieved?

Source: Internet
Author: User
For example, the result you want to achieve is the data that has been changed in the background, and the data that is being modified in the foreground is also displayed as the question. The result you want to achieve is the data that has been changed in the background, the previous table also shows that this data item is being modified.

Reply content:

For example, if you want to achieve the effect of which data is changed in the background, the data is also being modified in the front.

$ Table_name = 'user'; echo 'is creating a data table:'. $ table_name; // action code $ result = $ flag? 'Success': 'failed'; echo 'data table '. $ table_name. 'create'. $ result;

Because PHP is executed in sequence, the output is fine if it is executed.
This mainly involvesStr_repeat () and flush ()Two Functions and browser buffer size.
Different browsers have different buffer sizes and different str_repeat values. Note only this detail.

This is a bit difficult. You can judge the time when the page comes in. In addition, each time the data is modified, it is recorded to the database. Then compare the two time points. If they are similar, the data is displayed as being modified. This may be relatively simple. Of course there are many implementation schemes.

Main technologies: php ob Cache principles
PHP cache mechanism-OB Cache

You can refer to the onethink installation code:

Function create_tables ($ db, $ prefix = '') {// read the SQL File $ SQL = file_get_contents (MODULE_PATH. 'Data/install. SQL '); $ SQL = str_replace ("\ r", "\ n", $ SQL); $ SQL = explode ("; \ n", $ SQL ); // Replace the table prefix $ orginal = 'youyu _ '; $ SQL = str_replace ("' {$ orginal}", "'{$ prefix}", $ SQL ); // start to install show_msg ('start to install the database... '); foreach ($ SQL as $ value) {$ value = trim ($ value); if (empty ($ value) continue; if (substr ($ value, 0, 12) = = 'Create table') {$ name = preg_replace ("/^ CREATE table' (\ w + )'. */s "," \ 1 ", $ value); $ msg =" Create a data table {$ name} "; if (false! ==$ Db-> execute ($ value) {show_msg ($ msg. '... succeeded');} else {show_msg ($ msg. '... failed! ', 'Error'); session ('error', true) ;}} else {$ db-> ($ value) ;}} function show_msg ($ msg, $ class = '') {echo"

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.