首页 > 网站 > 建站经验 > 正文

如何轻松打造AS,P计数器

2019-11-02 14:25:37
字体:
来源:转载
供稿:网友

以下介绍用数据库实现简单计数器 
'下面存为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&

QQ网名总排行[www.la240.com/html2017/1/7/]
quot;) 
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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表