How to display dynamic content in static HTML

Source: Internet
Author: User
Keywords Static HTML
Tags added click content display file how to html php

Abstract: After the creation of their own web page static HTML, although the speed and SEO have a great upgrade, but the following problems have come, some of the content needs to be in static HTML dynamic display, such as the number of clicks, each click, click on the number added 1 times,

After the creation of their own web page static HTML, although the speed and SEO have a great upgrade, but then came the problem, some of the content needs to be in static HTML dynamic display, such as the number of clicks, each click, the number of clicks added 1 times, obviously this in the pure static page there is no way to achieve, Because the number of clicks is stored in the database, and pure static HTML and the database does not matter.

PHP and ASP are the same truth, want to display dynamic content in static HTML, you can only package the dynamic content, and then make the call, the following is a PHP update I wrote a number of examples, in the following file will be updated to the number of clicks into a PHP file, and finally in the form of JS output, This can be through JS dynamic clicks output to the static file inside, PHP update click the source code as follows:

< PHP

Include ("global.php");

$row = $art->get_row ($id);

mysql_query ("Update"). PRE. " Aspires ' Set ' hits ' = ' hits ' +1 where id= '. Intval ($row [' ID '])) or Die (ShowMsg ("Error in update hits!"));

$rows =mysql_fetch_assoc (mysql_query ($sql = "SELECT * from Doorsjk_article where id=". Intval ($row ["id"]));

$STR = $rows ["hits"];

?>

< PHP

echo "document.write" ("$str."); \ n ";

?>

Include ("global.php"); This sentence is included in the connection database file, $row = $art->get_row ($id); This sentence is received by the ID, has been made into a class to call, get the received ID, the following is very easy to understand, is to add the field hits of the datasheet to 1, and the final echo is to output the new hits.

Only need to include the updated number of PHP files in the use of the

Static pages can also call the text and so on to update the number of clicks, the example here is the number of clicks on the field stored in the database, but also most of the methods used, analogy, can also be "latest article", "article comments" and other dynamic content in the static HTML through the JS file to invoke.

Related Article

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.