Counter below introduction use database to implement simple counter
' Save As Count.asp ' below
<%
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & 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)
%>
<%
' Update weekly daily data
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 (Today ())-cint (year (lasthit))
P_month=cint (Month (now))-cint (month (lasthit))
P_day=cint (Today ())-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% ' > Today visits <%=rs ("Dayhit")%> times, this week visited <%=rs ("Weekhit")%> times, total visits <%=rs ("hit")%> times </td></tr> ');
<%rs.close
Set rs=nothing%>
' Use <script language= ' JavaScript1.1 ' src= ' count.asp ' ></script> to be called on the page to be counted.
Build a database: Build a count of the MDB library, and then build a table count, in the table field
Hit Digital type
Dayhit Digital Type
Weekhit Digital Type
Lasthit Date Type