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
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make a hit counter with HTML

    I was wondering if there is a way to make a hit counter using HTML. If any body knows of a way please reply.

  • #2
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    Hmm unfortunately you'll need a server side script for this, such as PHP or CGI. Your best bet is simply to download a premade counter script. Check out http://hotscripts.com for leads.
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #3
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    DesignersToolz wrote a simple counter script... then raf found a script in a comment at php.net to add st, nd, rd, th onto the end, here is the script put together:

    PHP Code:
    function nth($in)   
    {  
       if(
    strlen($in)>&& substr($in,-2,1)==1)  
           return 
    $in."th";  
       switch(
    substr($in,-1,1))  
       {  
           case 
    1:  
               return 
    $in."st";  
           case 
    2:  
               return 
    $in."nd";  
           case 
    3:  
               return 
    $in."rd";  
           default:  
               return 
    $in."th";  
       }  

    $getcount  =  fopen("count.txt",  "r");
    while  (!
    feof($getcount))
    {
            
    $oldcount  .=  fgets($getcount); 
    }
    fclose($getcount);
            
    $oldcount++;
    $storenew  =  fopen("count.txt",  "w");
            
    fputs($storenew,  $oldcount);
    fclose($storenew);

    print 
    nth($oldcount); 


  •  

    Posting Permissions

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