GuppY Help Center, help online, documentation and tutorials


You are here :   Welcome » Add a page view counter
    Print this page...

Add a page view counter

To add a visit counter (to count the number of times the page was displayed), you need to have a file to store the count data and modify a few lines in the sample.php file, in which you will increment the counter.

Find the following lines:
define('CHEMIN', '../');

After this lines add the following:
$­­file = CHEMIN.'data/my_counter.dtb';
$­­­­­­­­­count = ReadCounter($­­file) + 1;
WriteCounter($­­file, $­­­­­­­­­count);

Replace the file name "my_counter.dtb" by the name of your data file. (that you created to store this information)

Use the $­­­­count variable to display the counter value ( for example: echo $­­­­count; )

Creation date : 26/10/2006 @ 15:57
Category : - Sample PHP
Page read 16701 times