If you don’t have another stats tool, you can start tracking vistors to your site with this simple 1 minute mod. Start by creating a new table called “stats”. Here is the schema:
```php
#----------------------------
Table structure for stats
#----------------------------
CREATE TABLE stats
(
id
int(11) NOT NULL auto_increment,
userip
varchar(100) NOT NULL default ‘’,
userbrowser
varchar(255) NOT NULL default ‘’,
clickdate
datetime NOT NULL default ‘0000-00-00 00:00:00’,
referralsite
varchar(255) NOT NULL default ‘’,
page
varchar(255) NOT NULL default ‘’,
PRIMARY KEY (id
),
KEY clickdate
(clickdate
,userip
)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
#----------------------------
Records for table stats
#----------------------------
```
In the file index.php, add this to the bottom:
```php
mysql_query(“INSERT INTO stats
(userip,userbrowser,clickdate,referralsite,page) VALUES
(‘{$_SERVER[‘REMOTE_ADDR’]}’,‘{$_SERVER[‘HTTP_USER_AGENT’]}’,NOW(),‘{$_SERVER[‘REQUEST_URI’]}’,‘$target’)”) or die();
$results=mysql_query(“SELECT count(*) FROM stats”) or die();
if (mysql_result($results,0)>1000) {
mysql_query(“DELETE FROM stats”) or die();
}
?>
```
You can now access the table to see what your visitors are looking at and what the search engines are doing. The id column is used for the total number of hits at the time the entry was added. To keep the table from growing too large, it will purge itself once more the 1000 entries are made.