Web Page Hit Count
You can make your own Web Page Hit Counter using Mysql and PHP or just by PHP alone for a single page.This cannot be used for sites with multiple pages because every time the page loads it counts as new visit.
But you can make different tables for diffrent pages.For sites with myltiple pages check the multiple page counter from projects.
PHP version
no of visit--
Then the trim() function is used to remove any new line characters so we have an integer
This stores the no of visit in a text file named counter.txt you can change to your desired name.
You can have different files for different pages to use for multiple pages.
PHP and Mysql version
First of all create a database and call it Counter, also create a table in that database with 2 fields, ‘Page’ which as a 20 character (or more) varcharacter format and ‘Count’ which has an intermediate integer format.
Insert rows equal to the number of pages on your site, and enter ‘Count’ as zero.
At every page insert the following code:
This counts the visit and increments value to the variable in the table with corresponding page.
To display the hits put this code where ever you want.
Page Views ";
echo"".$row['Page']." ".$;row['Count']." ";
while($row=mysql_fetch_array($result))
{
echo"".$row['Page']." ".$;row['Count']." ";
}
echo "";
?>
To get the hits of all the page you can use this while loop to do that
while($row=mysql_fetch_array($result))
{
echo"".$row['Page']." ".$;row['Count']." ";
}
echo "";