Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how can calculate total number of hits

    hello frineds, i am developing a hosting directory web site on this site there will be the links of hosting websites, i want that when user click on a particular website link it will be recorded in the database how it could be done pls tell me thanks.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Have the links go to a counter and redirect page

    http://youdomain.com/site.asp?sideid=3423

    the siteid would be the id of the site in the database, so do a query with that in, then increment a field in the database for that site by 1, then redirect to the sites proper url

  • #3
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    I wrote this up along time ago for the sake of writing up scripts. This might help you do what you want to do. You might not want to use text documents as your databases.

    The way I wrote this code was so I didn't need to manualy create the text file databases. So this code is good just to give you the head start.
    Code:
    <%
    Dim FSO, Counter, File, Clicks, IntID
    
    IntID = Request.QueryString("ID")
    
    If IntID = 1 Or IntID = 2 Then
    
      Set FSO = CreateObject("Scripting.FileSystemObject")
      Counter = Server.MapPath("db\cc" & IntID & ".txt")
    
      On Error Resume Next
    
      Set File = FSO.OpenTextFile(Counter)
    
      Clicks = CLng(File.ReadLine)
      Clicks = Clicks + 1
      File.Close
    
      If Error Then
        Clicks = 1
      End If
    
      Set File = FSO.CreateTextFile(Counter, True)
    
    File.WriteLine(Clicks)
    File.Close
    
    End If
    
    
    If IntID = 1 Then
      Response.Redirect("http://link1.com?" & Clicks)
    ElseIf IntID = 2 Then
      Response.Redirect("http://second.net?" & Clicks)
    Else
      Response.Write "Add ?ID=1 or 2 to the end of this so that it will work"
    End If
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •