Du kan ikke lave en besøgstæller der er helt nøjagtig....... Du kan lave cookies der gør at en der har fået den ikke bliver talt med..... Du kan lave den på sessions og du kan lave på ip, men en med dynamisk ip kan blive talt 2 gange.....
Så det mest reelle vil være med Sessions da det gør man ikke bliver talt hver gang siden loades (f.eks. F5).......
Så tæller den ikke hvor mange forskellige besøgende, men hvor mange besøgende der har haft brug for siden......
<% ' I placed this in a function so I wouldn't have to worry about ' any namespace collisions. For example... if this was inline ' code and someone named a variable strSQL in a file this file ' gets included into you'd get an error. This way you don't and ' there's no chance of the variables overwriting one another! Function RetrieveAndIncrementCount() ' From adovbs.inc: Const adOpenKeyset = 1 Const adLockPessimistic = 2 Const adCmdText = &H0001
' Local variables Dim strFilename Dim strSQL Dim rsCounter Dim iCount
' Get filename and build SQL query strFilename = Request.ServerVariables("SCRIPT_NAME") strSQL = "SELECT page_name, hit_count FROM hit_count WHERE page_name='" & strFilename & "';"
' Open our recordset Set rsCounter = Server.CreateObject("ADODB.Recordset")
' If we've got a record then we read the current value ' If we don't then we create one, set the filename, and start at 0 If rsCounter.EOF Then rsCounter.AddNew
iCount = rsCounter.Fields("hit_count").Value End If
' Increment the count and update the DB rsCounter.Fields("hit_count").Value = iCount + 1 rsCounter.Update
' Close our connection rsCounter.Close Set rsCounter = Nothing
' Return the count (pre-incrementation). RetrieveAndIncrementCount = iCount End Function %>
og så en accessdb som hedder: counter_db.mdb med følgende: Tabel som hedder: hit_count Felt af typen tal som hedder: hit_count Felt af typen text som hedder: page_name
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.