Use a page counter with asp

Discussion in 'ASP General' started by Krechting, Dec 30, 2003.

  1. Krechting

    Krechting Guest

    Hi All,

    All I want is a small graphical page counter on my homepage.
    I'm using an access db and want to track how many times the
    pages were used (logged on to).
    All the graphical counters on the internet point to a website
    but my project runs on a localhost.

    Regards
    Marco
    Krechting, Dec 30, 2003
    #1
    1. Advertising

  2. Krechting

    Ray at Guest

    If you search Google, you will find a number of page counter solutions for
    ASP. You can use a component, store hits in a DB, use a file that increases
    in size with each visit, or probably something else. Once you get the
    number, you can build your image by having 10 gif images, 0.gif, 1.gif, etc.
    And then you use the value of your count to determine which images to
    display in your page.

    Page counters are so 90s though! :p

    Ray at work

    "Krechting" <> wrote in message
    news:...
    > Hi All,
    >
    > All I want is a small graphical page counter on my homepage.
    > I'm using an access db and want to track how many times the
    > pages were used (logged on to).
    > All the graphical counters on the internet point to a website
    > but my project runs on a localhost.
    >
    > Regards
    > Marco
    Ray at, Dec 30, 2003
    #2
    1. Advertising

  3. Krechting

    Curt_C [MVP] Guest

    just store the count in db.
    Increment by 1 each hit.
    Then just parse the count, replacing each digit with the individual
    graphic/image.

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    www.Darkfalz.com


    "Krechting" <> wrote in message
    news:...
    > Hi All,
    >
    > All I want is a small graphical page counter on my homepage.
    > I'm using an access db and want to track how many times the
    > pages were used (logged on to).
    > All the graphical counters on the internet point to a website
    > but my project runs on a localhost.
    >
    > Regards
    > Marco
    Curt_C [MVP], Dec 30, 2003
    #3
  4. Krechting

    Brynn Guest

    This is an old counter I used to use ... I made it for kicks
    It uses a table in a database. The table name is zcounter
    The column names are zpage and zhits
    This way you can also have different pages being counted if you want.

    Another thing I did is have it create a cookie for the user that
    expires in a day. This will let a users computer only add to the
    counter once a day ... granted, only if they have cookies on.

    I also, instead of images, used the CSS at the top to control design
    as to avoid images, but you could easily change that in the code.

    Have fun ... I will make an updated counter script and have it on my
    website sometime in the next couple weeks, just for fun :)

    Brynn
    www.coolpier.com (new website under construction)






    <style type="text/css">
    td.coolpier_counter {background-color:#F4F4F4; color:#336699;
    font-size:16; font-weight:bolder;}
    </style>

    <%
    '//CHANGE CONNECTION STRING
    connString="your connection string"

    Sub coolpier_counter(thePage)
    '//Need a table called zcounter
    '//Two fields: zpage (text), zhits (number)
    Set conn=Server.CreateObject("ADODB.Connection")
    conn.Open(connString)
    If Request.Cookies("zhit")<>"1" Then
    zsql="UPDATE zcounter SET zhits=zhits+1 WHERE
    zpage='" & thePage & "';"
    conn.Execute(zsql)
    Response.Cookies("zhit")="1"
    Response.Cookies("zhit").expires=Date()+1
    End If
    zsql="SELECT zhits FROM zcounter WHERE zpage='" &
    thePage & "';"
    Set rs=conn.Execute(zsql)
    theCount=rs(0)
    rs.Close: Set rs=nothing
    conn.Close: Set conn=nothing

    With Response
    .Write "<table align=center cellpadding=3
    cellspacing=1 border=0><tr>"
    .Write "<td class=""coolpier_counter"">Hits: </td>"
    numLength=Len(theCount)
    For n=1 to Len(theCount)
    .Write "<td class=""coolpier_counter""
    width=15>" & Mid(theCount, n, 1) & "</td>"
    Next
    .Write "</tr></table>"
    End With
    End Sub

    coolpier_counter("yourpage.asp")
    %>

    On 30 Dec 2003 08:24:24 -0800, (Krechting)
    wrote:

    >Hi All,
    >
    >All I want is a small graphical page counter on my homepage.
    >I'm using an access db and want to track how many times the
    >pages were used (logged on to).
    >All the graphical counters on the internet point to a website
    >but my project runs on a localhost.
    >
    >Regards
    >Marco
    Brynn, Jan 3, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. The Eeediot
    Replies:
    3
    Views:
    2,215
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  2. George2
    Replies:
    1
    Views:
    782
    Alf P. Steinbach
    Jan 31, 2008
  3. Roland Ramirez

    ASP 3.0, Need help with Page Counter Component

    Roland Ramirez, Jan 30, 2004, in forum: ASP General
    Replies:
    1
    Views:
    116
    Aaron Bertrand - MVP
    Jan 30, 2004
  4. Roland Ramirez

    Page Counter Component, ASP 3.0

    Roland Ramirez, Jan 30, 2004, in forum: ASP General
    Replies:
    3
    Views:
    400
    A. Webmaster
    Feb 2, 2004
  5. Paul W Smith

    ASP Page Counter

    Paul W Smith, Aug 15, 2008, in forum: ASP General
    Replies:
    32
    Views:
    508
    Phillip Windell
    Sep 12, 2008
Loading...

Share This Page