content complete counter
Posted: Fri Mar 05, 2004 8:07 pm
alright what about this one? what do I do here and what code do I put in my page for this counter?
Also what counter is one the main page of this site? which counter is that one cuz I am trying to get mine like that.
Code: Select all
<?php
/*
3C, by Andrew Walton.
Under the GPL, see them for a copy of the license.
NOTE TO ADMIN: use some artistic freedom with the PageId field.
You can either have it report a number (like in my system), report the page request,
report the actual script name, or any of the above.
CREATE TABLE counter (
PageId int(10) unsigned NOT NULL default '0',
Ip varchar(16) NOT NULL default '',
Request varchar(255) default NULL,
Referer varchar(255) default NULL,
Usr_Agent varchar(255) default NULL,
Date varchar(30) NOT NULL default '',
Time varchar(30) NOT NULL default '',
Id int NOT NULL auto_increment,
PRIMARY KEY (Id)
) TYPE=MyISAM;
For Commentable Blog users!!
Use connect2mysql($db) instead of spending the extra lines for the connection routine.
*/
//determines the PageId.
if (!empty($_POSTї'Id'])) {
$Id = $_POSTї'Id'];
} elseif (!empty($_GETї'Id'])) {
$Id = $_GETї'Id'];
} else {
$Id = 31415;
}
$connex = mysql_pconnect("localhost", "username", "password");
mysql_select_database("the database's name");
$q="INSERT INTO counter VALUES ('".$Id.
"','".$_SERVERї'REMOTE_ADDR'].
"','".$_SERVERї'REQUEST_URI'].
"','".$_SERVERї'HTTP_REFERRER'].
"','".$_SERVERї'HTTP_USER_AGENT'].
"','".date("m-d-Y").
"','".date("H:m:s").
"','')";
$r=mysql_query($q) or die("ERROR");
//use dberr if using the commentable blog system
/* not the best way of counting hits if you dont want to include your own hits.
On request I can help show you how to patch this..
(Otherwise, it looks good to include all hits ;)
*/
$query="select count(id) from counter";
$ret=mysql_query($query);
while($w=mysql_fetch_array($ret)) {
$count=$wї'count(id)'];
}
/* echo is MARGINALLY faster because it does not return a sucess value. */
echo "Hits: {$count}";
?>Also what counter is one the main page of this site? which counter is that one cuz I am trying to get mine like that.