Home >Backend Development >PHP Tutorial >Implement click statistics in static pages_PHP tutorial

Implement click statistics in static pages_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:04:181257browse

Using the server-side method of generating static pages in an article publishing system can effectively reduce the load on the server, which is especially effective for high-traffic websites. But since the generated page is a static page, what will it look like when it is generated and how will it be displayed? How to display the number of times common articles have been read?
After consideration, the following solution can be used:
When generating a static page, an article id will be generated and stored in the database. Then when we make the article template, we can make an article based on the article id. The template contains the following statements:

Instructions:
Using the template When generating an article, perform pattern matching on "#articleId#" and replace it with the id number of the newly added article.
 
The counter.asp file is an asp file that implements counting
<%
''###################
''######Start#########
''BY Wang Xiangchao
''###################
dim articleId,sqlStr,hits
articleId=int(trim(request.querystring("articleId")))
sqlStr="update articles set hits=hits+1 where articleId=" & articleId
''Add 1 to the number of article hits
conn.execute(sqlStr)
''Read the number of article clicks
hits=conn.execute("select hits from articles where articleId=" & articleId)(0 )
%>
''Print out the number of article hits
document.write(<%=hits%>)



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445214.htmlTechArticleUsing the server-side method of generating static pages in the article publishing system can effectively reduce the burden on the server, especially for large users. Traffic websites are very effective. But since the generated page is a static page...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn