復(fù)制代碼 代碼如下:
%
'//hittime 日期型:獲得上次訪問(wèn)時(shí)間
'//hits 數(shù)字型:獲得總瀏覽量
'//hitsday 數(shù)字型:獲得今天瀏覽量
'//hitsweeks 數(shù)字型:獲得本周瀏覽量
'//hitmonths 數(shù)字型:獲得本月瀏覽量
'數(shù)據(jù)庫(kù)中 添加這5個(gè)字段。
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from qwbmnewssss where id=26",conn,1,3
if rs1.eof and rs1.bof then
response.write "erry"
else
hittime = rs1("hittime") '獲得上次訪問(wèn)時(shí)間
dim dayNow,monthNow,weeknow
dayNow = day(date()) '現(xiàn)在幾號(hào)
monthNow = month(date()) '現(xiàn)在幾月
weekNow = weekday(date()) '現(xiàn)在星期幾 0為星期天
rs1("hits") = rs1("hits") + 1 '總瀏覽次數(shù) + 1
if datediff("d",hittime,now()) = 0 then '比較最后訪問(wèn)日期與現(xiàn)在的時(shí)間 天數(shù)
rs1("hitsday") = rs1("hitsday") + 1 '今天的瀏覽量 + 1
else
rs1("hitsday") = 1 '今天的瀏覽量 = 1
end if
if monthNow = month(hittime) then
rs1("hitmonths") = rs1("hitmonths") + 1 '本月的瀏覽量 + 1
else
rs1("hitmonths") = 1 '本月的瀏覽量 + 1
end if
if datediff("d",hittime,now()) > 6 then '在處理星期的期的時(shí)候有一個(gè)問(wèn)題,如果上一個(gè)時(shí)間是星期五,下一次訪問(wèn)是下個(gè)星期的星期二,記錄還是疊加。
rs1("hitsweeks") = 1
else
if weekNow > 1 then
rs1("hitsweeks") = rs1("hitsweeks") + 1
else
weekNowss = weekday(hittime) '上次訪問(wèn)的星期幾
if weekNow = weekNowss then
rs1("hitsweeks") = rs1("hitsweeks") + 1
else
rs1("hitsweeks") = 1
end if
end if
end if
rs1("hittime") = now() '更新最后的訪問(wèn)題意
rs1.update
%>
時(shí)間比較:%=datediff("d",hittime,now())%>br />
當(dāng)前時(shí)間:%=now()%>br />
最后點(diǎn)擊時(shí)間:%=hittime%>br />
當(dāng)前天:%=dayNow%>br />
當(dāng)前月:%=monthNow%>br />
當(dāng)前周:%=weekNow%>br />
總共瀏覽量:%=rs1("hits")%>br />
今天訪問(wèn)量:%=rs1("hitsday")%>br />
星期訪問(wèn)量:%=rs1("hitsweeks")%>br />
當(dāng)月訪問(wèn)量:%=rs1("hitmonths")%>br />
%
end if
rs1.close
set rs1=nothing
%>
您可能感興趣的文章:- ASP制作在線人數(shù)統(tǒng)計(jì)實(shí)例
- 統(tǒng)計(jì)有多少行JS代碼和ASP代碼
- ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類(lèi)
- asp論壇在線人數(shù)統(tǒng)計(jì)研究
- ASP訪問(wèn)數(shù)量統(tǒng)計(jì)代碼
- ASP.NET 統(tǒng)計(jì)圖表控件小結(jié)
- php模仿asp Application對(duì)象在線人數(shù)統(tǒng)計(jì)實(shí)現(xiàn)方法
- ASP.NET中使用Application對(duì)象實(shí)現(xiàn)簡(jiǎn)單在線人數(shù)統(tǒng)計(jì)功能
- 簡(jiǎn)單的ASP統(tǒng)計(jì)制作實(shí)例