Results 1 to 11 of 11

Thread: my hit counter

  1. #1

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609

    my hit counter

    i have my page designed in modules and the page displayed being passed through the address string (values). anbyway, i dont know how to explain that part clearly but its noyt really neccessary for now.

    the thing i want to ask is, should i have it only tally one to the counter on the first time the user views the first page, or session ? or even use a cookie and count the user every week or something.

    any comments ?

  2. #2
    Aurilus
    Guest
    I'd say have a counter for each page (ie store seperate values for each page, not just one big number) and have it incremented each time the page is viewed.. this is the easiest way and will give you some idea of how many ppl (both new and repeat visitors) visit your page. Cookies don't always work in all circumstances as some people disable them and this can screw up your site if you rely on them.

  3. #3

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    ok, thats a good idea actually. should i store their IP's as well ??

  4. #4
    Aurilus
    Guest
    Not unless you have to. The only reason I can think of storing IPs would be to track repeated users, but many ISPs actually assign a dynamic (different) IP each time to dial-up users, so this method of tracking won't always work.

  5. #5
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153

    how?

    How would you create the Hit counter? How do you retrieve a variable from a database file (text file). ?Extract the number from a text file, add 1, then save back to text file? I'm new to PHP. If you want to visit my site @ www.nada.d2g.com\junk.php this is bout the only thing i have made in php so far.

  6. #6

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    when i get home i'll post the code 4 u, thing is that now it doesnt appear to be working, but i'll fix it 4 u

  7. #7

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    PHP Code:
    <?PHP
    $link 
    mysql_connect("localhost""root");
    mysql_select_db("ubunreal");

    $temp_page_count mysql_result(mysql_query("SELECT count FROM counter"),0,"count");
    $temp_page_count++;

    mysql_query("UPDATE counter SET count=$temp_page_count");}

    ECHO 
    mysql_result(mysql_query("SELECT count FROM counter"),0,"count");    
    ?>
    there is the code i use, made it myself too anyway, it simply logs into a MySQL DB server and extracts the existing value in the cell, adds one to it then runs another query to replace the updated value, after that there is another query to get the resuly back out and display it to the HTML output.

    need any more explanation then pls just ask

  8. #8
    ricmitch_uk
    Guest
    There's plenty of free counters out there that do all of the above and more.

    Do a search on SourceForge or on Google.

  9. #9
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Bah make it yourself its much more rewarding

  10. #10
    ricmitch_uk
    Guest
    I do most of my code myself, but I do occasionally scarf bits from Open Source things.

  11. #11

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Bah make it yourself its much more rewarding
    couldnt agree more, thats why i try and do everything mysqlf before seeking other peoples code

Posting Permissions

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



Click Here to Expand Forum to Full Width