1.

Solve : Inline Counter?

Answer»

Is there a way to make an inline counter?? Like so that when other PEOPLE go on, it counts but other people viewing the site don't see how many people have viewed it?? So that only I can see it.? or so that everytime someone VIEWS it, I get some sort of email?/// :-? :-?Ah, Mr. Google, you didn't Google for this, did you?  Shame, shame.  There are many hit counters; see http://www.google.com/search?hl=en&lr=&q=hit+counters&btnG=Search.  However, many of the free ones will display a visible hit counter on the page.  If you want a counter that does not appear on the page, you may have to use a fee-based service.  In that case, you would be probably logon to a WEBSITE to see the stats for your site.

If you use a fee-based hosting service, you might also take a look at the site stats in your web server admin panel for your site.  Most hosting services provide a way for clients to view statistics on website traffic.  However, this may be in quite a different format than the stats you would get from an independent hit counter service.  If your web server is PHP-enabled (in fact this will work with any server-side technology) you can simply increment a counter contained in a text file or database, viewable only by you.

How would you like to proceed?Well, I am using mbhosting at the moment and I think it is php enabled. So Would you care to give a small explanation?There are some URL tracking service through PHP. You need to study a PHP
tutorial and possibly, MYSQL also).

You really don't need to study ANYTHING deep. Just a introductory knowledge
and in those tracking service you will get instructions on how to implement.You can create a simple page view counter like this:

Code: [Select]<?php

// Change this to something suitable - one file per web page!
$filename = '/path/to/trackingfile';

// If file doesn't exist, create it and set contents to zero
if (!file_exists($filename)) {
  $handle = fopen($filename", 'w');
  fwrite($handle, '0');
  fclose($handle);
}

$counter=file_get_contents($filename);
$counter++;
file_put_contents($filename, $counter);

?>This works for PHP 5+ but would need re-writing for earlier versions.  Put it at the top of the page that you want to track.  Make sure it's a .php page rather than .html.



Discussion

No Comment Found