codice:
<%
Dim CounterFile
CounterFile = "counter.mdb"
Dim CookieSwitch
CookieSwitch = "on"
Dim CounterDataConn
Dim CounterSQL
Dim CounterRs
Dim CounterHits
Id = Clng(CounterId)
Set CounterDataConn = Server.CreateObject("ADODB.Connection")
CounterDataConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath(CounterFile)
CounterSQL = "SELECT * FROM Counter WHERE Id=" & Id
Set CounterRs = CounterDataConn.Execute(CounterSQL)
If CounterRs.EOF then
CounterSQL = "INSERT INTO Counter(Id,Count) Values(" & Id & ",1)"
Set CounterRs = CounterDataConn.Execute(CounterSQL)
CounterHits = 1
Else
If CounterAction = "GetStatus" then
CounterHits = Clng(CounterRs("Count"))
Else
If NOT Request.Cookies("CounterHits") = "" and Id = 1 then
CounterHits = Request.Cookies("CounterHits")
Else
CounterHits = Clng(CounterRs("Count"))
CounterHits = CounterHits + 1
CounterSQL = "UPDATE counter SET count = " & CounterHits & " where id = " & id
CounterRs = CounterDataConn.Execute(CounterSQl)
Response.Cookies("CounterHits") = CounterHits
End If
End If
End If
Set CounterRs = nothing
CounterDataConn.Close
Set CounterDataConn = nothing%>
questo lo metti nella pagina dove vuoi visualizzare il contatore; che richiamerai con
codice:
<%Response.Write CounterHits%>
creati un dbase chiamato 'counter.mdb' con una tabella 'counter' i campi 'id e 'count'.
tanto per cominciare, poi se vuoi le statistiche cerca nel forum statistiche weppos