欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【如何轻松打造ASP计数器】,下面是详细的分享!
如何轻松打造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%>
建立数据库:建一个count的MDB库,再建一个表count,表中字段为
hit 数字型
dayhit 数字型
weekhit 数字型
lasthit 日期型
用<script language="JavaScript1.1" src=http://www.chinaz.com/program/2006/0918/"count.asp"></script>在要统计的页面调用即可.
以上所分享的是关于如何轻松打造ASP计数器,下面是编辑为你推荐的有价值的用户互动:
相关问题:asp程序:试利用Cookie来制作一个网站的计数器
答:int counter; if (Request.Cookies["counter"] == null) counter = 0; else { counter = int.Parse(Request.Cookies["counter"].Value); } counter++; Response.Cookies["counter"].Value = counter.ToString(); Response.Cookies["counter"].Ex... >>详细
相关问题:淘宝-计数器的制作~观察浏览量的东西~
答:当然要学ASP或者PHP之类的动态网页技术。 网上有很多这方面的代码,自己仔细研究下一定没问题了。 active server pager(动态active server pager(动态服务器主页,简称asp),通过读写服务器的文件,结合script语言(vbscript或能。现流行的asp教... >>详细
相关问题:怎么用ASP技术做一个刷新不计数的网站计数器啊??...
答:试一下这个! 主要功能介绍:如果是相同IP,在10分钟之后登陆,计数器加1!而在不同IP在任何时间登陆都可+1 http://www.5image.com/ntcount.rar(本文件为计数器的图片和文本) >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
