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.