CREATE TABLE counter (
time date default NULL,
ip varchar(30) default NULL,
noofvisit bigint(40) default '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
<?php
session_start();
$ip= $_SERVER['REMOTE_ADDR'];
//connect to database
$con = mysql_connect('localhost','root','pari') or die ("Unable to connect : ".mysql_error());
$selDat = mysql_select_db('practise',$con) or die ("Unable to sel database : ".mysql_error());
$sql="SELECT * FROM counter WHERE ip='$ip'";
$result=mysql_query($sql) or die ("Unable to query : ".mysql_error());
$count=mysql_num_rows($result);
$no_ofvisit = mysql_fetch_array ($result);
$visit = $no_ofvisit['noofvisit'];
if($count=="0"){
$sql2="INSERT INTO counter (time, ip, noofvisit)VALUES( NOW(), '$ip', 1)";
$result1 = mysql_query($sql2);
}
else
{
$sql2="update counter set time = NOW(), ip = '$ip', noofvisit = '$visit'+1 where ip = '$ip'";
$result1 = mysql_query($sql2);
}
?>
use the above script it will reduce the table size