ASP program to show the number of times the article has been read in HTML

Source: Internet
Author: User
Program | show in the article publishing system using server-side to generate static pages can effectively reduce the burden on the server, especially for large traffic site is very effective. But since the generated is static page, what is the generation, what is the display, for the article common article is read how many times show it?

After consideration, the following schemes can be used to resolve:

When generating a static page, the ID of an article is generated and stored in the database, so we can make a fuss about the ID of the article when we create the template for the article, and the article template contains the following statements:

<script src= "counter.asp?articleid=<%= #articleId #%>" ></script >

Description:

When you generate an article from a template, match the "#articleId #" to the pattern, replacing the ID number of the newly added article.

counter.asp file is an ASP file for implementing a Count

<%

'###################

' ##### #开始 #########

Dim articleid,sqlstr,hits

Articleid=int (Trim (Request.QueryString ("ArticleID"))

sqlstr= "Update articles set hits=hits+1 where articleid=" & ArticleID

' Click on a number plus 1 for the article

Conn.execute (SQLSTR)

' Read the number of clicks on the article

Hits=conn.execute ("Select hits from articles where articleid=" & ArticleID) (0)

%>

' Print out the number of clicks on the article

document.write (<%=hits%>)



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.