Simple ASP Counter

xiaoxiao2021-03-06  84

The following introduction Database implementation Simple counter 'The following is a count.asp <% set conn = server.createObject ("adodb.connection") conn.CreateObject ("AdoDb.Connection") Conn.Pen "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 = conn.execute (SQL)%> <% 'update weekly daily data LastHit = RS ("Lasthit") TDATE = Year (now ()) & "-" & month (now () ) & "-" & day (now ()) f 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 = "& requirements) conn.execute (SQL) p_year = cint (Year (NOW ())) - CINT (Year (LastHit)) P_MONTH = CINT (Month (now ()) ) -Cint (lasthit)) p_day = cint (day (now ())) - CINT (day (lasthit)) period_time = (p_year * 12 p_month) * 30 p_day) if cint = < 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> Today's visit <% = rs ("dayhit")%> times, this week visits <% = rs ("weekhit")%> times, total access <% = r (" HIT ")%> times ');

<% rs.close set = Nothing%> 'Use