html / xhtml, css, php, mysql, javascript, asp, seo, web management, semantics, accessibility and more.
Hit counters are used to track the amount of visitors there have been to a cetain page. I have looked through the internet and I have come up with 2 different ways to produce a hit counter.
In category php.
Posted by Joseph Skidmore on 11.09.05.
Hit counters are used to track the amount of visitors there have been to a cetain page. I have looked through the internet and I have come up with 2 different ways to produce a hit counter.
1. Flat Files (Storing data in a *.txt or *.dat file)
2. Database (using MySQL or something similar to store the data in)
Each way is the same, there is no difference between them. I have written a description on each of these 2 methods together with the scripts to produce your own hit counters. Each script will be given with a line by line explanation of all the details of the code.
Storing data in a *.txt or *.dat file. Now the script will create the file for you if you haven't already created it so you don't need to worry about that.
This is the way to create a hit counter using a flat file. The second option uses MySQL to keep track of all the hits to your site.
To start you will need to create your database, I will assume that you already know how to do this, lets call the database hits. The second thing you need to do is add a query to our database, here is the query:
We have just created a table called counterlog and a table field called hits. In this field we will be storing the amount of hits.
Lets break down this code to plain English shall we.
You will now be able to have your custom hit counter on your page with the speed of mysql, enjoy!