ASP访问统计计数器代码
来源:西路科技 时间:2008-03-20 13:33:00
以下介绍用数据库实现简单计数器,功能实现统计网站每日访问,每周访问及总访问量的统计,使用js调用
下面存为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="count.asp"></script>在要统计的页面调用即可.
建立数据库:建一个count的MDB库,再建一个表count,表中字段为:
hit 数字型
dayhit 数字型
weekhit 数字型
lasthit 日期型
标签:统计,计算器,asp
0
投稿
猜你喜欢
基于jsp实现新闻管理系统 附完整源码
2023-07-10 15:35:53
Tensorflow使用支持向量机拟合线性回归
2021-01-20 03:38:42
asp如何实现歌曲在线点播?
2010-05-19 21:32:00
sqlserver 复制表 复制数据库存储过程的方法
2024-01-21 17:01:00
thinkphp实现多语言功能(语言包)
2024-05-22 10:05:21
python中property和setter装饰器用法
2022-04-20 21:38:03
python图像处理模块Pillow的学习详解
2021-06-03 19:19:03
百万级asp分页存储过程代码(ver2.0)
2007-12-17 13:13:00
python 处理数字,把大于上限的数字置零实现方法
2022-11-13 09:20:56
bootstrapValidator bootstrap-select验证不可用的解决办法
2024-04-10 13:53:06
Python数据库反向生成Model最优方案示例
2023-11-02 18:37:36
python 读取文本文件的行数据,文件.splitlines()的方法
2021-07-18 16:58:05
python 解决mysql where in 对列表(list,,array)问题
2024-01-27 06:34:23
简介JavaScript错误处理机制
2024-04-19 10:26:43
python实现在遍历列表时,直接对dict元素增加字段的方法
2021-08-10 05:44:15
rollup3.x+vue2打包组件的实现
2024-05-22 10:43:40
OpenCV 边缘检测
2023-08-19 22:54:20
Linux中安装Python的交互式解释器IPython的教程
2023-09-14 05:50:06
Python格式化日期时间操作示例
2022-04-23 23:07:19
利用Python校准本地时间的方法教程
2021-06-24 06:51:41