ASPカウンターを簡単に作成
著者:Eve Cole
更新時間:2009-06-23 16:43:18
以下のデータベースを使用して単一のカウンタを実現します
'下に残っているのはcount.aspです
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("count.mdb")
%>
<%エラー発生時は次の再開%>
<%sql="更新回数セット hit=hit+1%><%conn.Execute(sql)%>
<%sql = "カウントから * を選択
set rs=conn.execute(sql)
%>
<%
'更新周每日データ
lasthit=rs("ラストヒット")
tdate=year(Now()) & "-" & month(Now()) & "-" & day(Now())
トリム(lastit)=トリム(tdate)の場合、
sql="サイト設定の更新 dayhit=dayhit+1 where id="&request("id")
conn.Execute(SQL)
' 応答.書き込み "成功"
それ以外
sql="更新サイト設定 dayhit=1 where id="&request("id")
conn.Execute(SQL)
' 応答.書き込み "エラー"
終了する場合
sql="サイト設定の更新 lasthit='"&tdate&"' where ID="&request("id")
conn.Execute(SQL)
p_year=CInt(year(Now()))-CInt(year(lastit))
p_month=CInt(month(Now()))-CInt(month(lastit))
p_day=CInt(day(Now()))-CInt(day(lastit))
period_time=((p_年*12+p_月)*30+p_日)
if cint(period_time)=<cint(7) then
sql="サイトセットの更新weekhit=weekhit+1 where id="&request("id")
conn.Execute(SQL)
それ以外
sql="更新サイトセットweekhit=1 where id="&request("id")
conn.Execute(SQL)
終了する場合
%>
document.write('<tr><td width="100%">今日访问<%=rs("dayhit")%>次,本周访问<%=rs("weekhit")%>次,总访问<%=rs("hit")%>次</td></tr>');
<%rs.close
rs=何も設定しない%>
'用<script language="JavaScript1.1" src="count.asp"></script>要统计の页面调用即可。
データベース ファイルの構築: 1 つのカウントの MDB ファイル、再構築された 1 つのテーブル カウント、表中フィールド
ヒット数字型
デイヒット数字型
ウィークヒット数字型
lasthit日期型