PHP Tutorial : Simple views counter script

Hi,
In this php tutorial you will learn the simple way to build a script which counts how many times a page is viewed. For this, we can use a mysql database table and a simple php script.

<?php
$pagename = $_SERVER['PHP_SELF'];
$sql = “select * from mysqltable where page = ‘$pagename’”;
$rs = mysql_query($sql);

if($rs) {
$row=@mysql_fetch_object($rs);
$counter = $row->counterfield;
//update the stats,…………….

Read PHP Tutorial : Simple views counter script »