Home  >  Article  >  php教程  >  在静态页面中实现点击数统计

在静态页面中实现点击数统计

WBOY
WBOYOriginal
2016-06-13 11:20:41843browse

在文章发布系统中采用服务器端生成静态页面的方法可以有效减轻服务器的负担,特别是对大流量网站非常有效。但是既然生成的是静态页面,生成时是什么样,显示就是什么样了,对于文章常见文章被阅读次数怎么显示呢?
经考虑,可用如下方案解决:
生成静态页面时会产生一个文章的id存到数据库中,那么我们在制作文章的模板的时候就可以在这个文章的id上做文章,文章模板包含以下语句:

说明:
在利用模板生成文章时,把"#articleId#"进行模式匹配,替换为新添加的文章的id号。
 
counter.asp 文件为实现记数的asp文件
''###################
''######开始#########
''BY 王向超
''###################
dim articleId,sqlStr,hits
articleId=int(trim(request.querystring("articleId")))
sqlStr="update articles set hits=hits+1 where articleId=" & articleId
''给文章点击数加1
conn.execute(sqlStr)
''读出文章点击数
hits=conn.execute("select hits from articles where articleId=" & articleId)(0)
%>
''打印出文章点击数
document.write()



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