HI!
On this occasion I bring a small script "Count", to see if anyone's worth, most of all to practice a bit of knowledge.
counter.php
Kod:
<title> Who visits my website [By SkarY]</title>
<?php
/*
Who visit my website By SkarY
*/
class count{
var $con;
var $tabla;
function add(){
#---Replace your details---
$host = 'localhost';
$user = 'root';
$pwd = 'root';
$db = 'test';
$this -> tabla = 'counter';
#-----------------------------
$this -> con = mysql_connect($host,$user,$pwd) or die ("Connection failed!");
$select_db = mysql_select_db($db,$this->con);
$ip = $_SERVER['REMOTE_ADDR'];
$pag = __FILE__;
$ins = "INSERT INTO $this->tabla(ip,page) VALUES('$ip','$pag')";
mysql_query($ins,$this -> con);
}
function show(){
$mos = mysql_query("SELECT * FROM $this->tabla",$this -> con);
$amount = mysql_num_rows($mos);
if($amount !=0){
echo $amount;
}else{
echo "1";
}
}
}
$counter = new count;
$counter -> add();
echo 'views: '; $counter -> show();
?>
counter.sql
Kod:
USE test; -- Change the name of your bd
CREATE TABLE counter( -- Table Name Change
ip varchar(12),
page text
);
Link Versión English: http://pastebin.com/m0DDYuxg
Link Versión Spanish: http://pastebin.com/r7rMgB7j
Hope you like.
Greetings!