轻松打造ASP计数器

2016-01-29 17:48 2 1 收藏

轻松打造ASP计数器,轻松打造ASP计数器

【 tulaoshi.com - ASP 】

  以下介绍用数据库实现简单计数器
'下面存为count.asp
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("count.mdb")
%
<%on error resume next%
<%sql="update count set hit=hit+1%<%conn.Execute(sql)%
<%sql = "select * from count
set rs=conn.execute(sql)
%
<%
'更新每周每日数据
lasthit=rs("lasthit")
tdate=year(Now()) & "-" & month(Now()) & "-" & day(Now())
if trim(lasthit)=trim(tdate) then
sql="update site set dayhit=dayhit+1 where id="&request("id")
conn.Execute(sql)
' response.write "success"
else
sql="update site set dayhit=1 where id="&request("id")
conn.Execute(sql)
' response.write "error"
end if
sql="update site set lasthit='"&tdate&"' where ID="&request("id")
conn.Execute(sql)

p_year=CInt(year(Now()))-CInt(year(lasthit))
p_month=CInt(month(Now()))-CInt(month(lasthit))
p_day=CInt(day(Now()))-CInt(day(lasthit))
period_time=((p_year*12+p_month)*30+p_day)
if cint(period_time)=<cint(7) then
sql="update site set weekhit=weekhit+1 where id="&request("id")
conn.Execute(sql)
else
sql="update site set weekhit=1 where id="&request("id")
conn.Execute(sql)
end if
%
document.write('<tr<td width="100%"今日访问<%=rs("dayhit")%次,本周访问<%=rs("weekhit")%次,总访问<%=rs("hit")%次</td</tr');
<%rs.close
set rs=nothing%

'用<script language="JavaScript1.1" src="http://img.jcwcn.com/attachment/portal"</script在要统计的页面调用即可.

建立数据库:建一个count的MDB库,再建一个表count,表中字段为
hit 数字型
dayhit 数字型
weekhit 数字型
lasthit 日期型
 

来源:https://www.tulaoshi.com/n/20160129/1503058.html

延伸阅读
标签: PHP
  --------------------------------------------------------------------------------   请保持文章的完整性   --------------------------------------------------------------------------------------   <?   //counter.php All rights reserved http://sports98.126.com   ...
标签: Java JAVA基础
  计数器是一般网站必备的东东,别小看它了,每当站长看着小小计数器上的数字飞速增长的时候,感觉实在是好极了。以前我们用cgi、asp来写计数器,这方面的文章很多了,在这里,我们将会采用目前比较流行的jsp技术演示如何做一个计数器。 其中我们用到了两个文件,test.jsp文件用于在浏览器中运行,counter.java是后台的一个小java bean程...
标签: Java JAVA基础
  <!-- JSP-Hitcounter counts sessions. Copyright (C) 2000 Jesper Schmitz Mouridsen. Visit www.webappcabaret/jsm2/webapps.jsp?find=jsphcs for more info. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software...
标签: PHP
       <?php         $counterFile = "balong.txt";//存储数值的文件名几路径      function displayCounter($counterFile) {    $fp = fopen($counterFile,"rw");    $num = fgets($fp,5);    $num +...
标签: PHP
  最近嘉新的计数器改成文本的了,不过正好.. //count.php -js 应用版 <? $a=file("http://www.jx.zj.cninfo.net/cgi-bin/count.cgi?df=wfnic.dat"); print "document.write('<b$a[0]</b');"; ? //php 直接版 <? $a=file("http://www.jx.zj.cninfo.net/cgi-bin/count.cgi?df=wfnic.dat"...

经验教程

527

收藏

44
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部