<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$data_array=getdate();
mysql_connect("localhost","root") or die ("Cannot connect to your db");
mysql_select_db("counter") or die ("cannot select your db");
$q=mysql_query("select * from count where day=$data_array[mday] and month=$data_array[mon]");
$a=mysql_fetch_row($q);
if ($a[3])
{
$counter_today=$a[3];
$counter_today++;
$q=mysql_query("UPDATE count set count=$counter_today where day=$data_array[mday] and month=$data_array[mon] ");
}
else
{
$q=mysql_query("INSERT INTO count ( `day` , `month` , `year` , `count` ) VALUES ($data_array[mday],$data_array[mon] , $data_array[year], 1)")or die ("cannot ...");
$counter_today=1;
}
echo "<h4> Today : ";
print date("m/d/y",time());
echo "</h2>Today visitors :".$counter_today;
echo '<div style="border-style:solid; position: absolute; width: 960px; height: 200px; z-index: 1; left: 10px; top: 100px; background-color:#E7EEF8" id="layer0">';
$q=mysql_query("select count from count where month=$data_array[mon] " ) or die ("cannot select all");
$counter_month=0;
while ($a=mysql_fetch_row($q))
$counter_month=$counter_month+$a[0];
$total_count=0;
$q=mysql_query("select * from count ") or die ("cannot select all");
while ( $a=mysql_fetch_row($q) )
{
$color="8AA2D2";
$total_count=$total_count+$a[3];
if ( $a[0]==$data_array[mday] and $a[1]==$data_array[mon] and $a[2]==$data_array[year] )
{
$color="993333";
$today=(integer) (($a[3]*200)/$counter_month);
echo "<div style=\"position: absolute; height:".$today;
echo "; left:".$data_array[mday]*30 ."; bottom: 0px; background-color:#".$color."; \" id=\"layer".$data_array[mday]."\">";
printf("%02d",$today/2 );
echo "%</div>\n";
}
elseif ($a[1]==$data_array[mon] and $a[2]==$data_array[year])
{
$color="8AA2D2";
$today=(integer) (($a[3]*200)/$counter_month);
echo "<div style=\"position: absolute; height:".$today;
echo "; left:".$a[0]*30 ."; bottom: 0px; background-color:#".$color."; \" id=\"layer".$data_array[mday]."\">";
printf("%02d",$today/2 );
echo "%</div>\n";
}
$today=0;
}
echo "<div style=\"position: absolute; width: 379px; height: 66px; z-index: 2; left: 12px; top: 311px\" id=\"layer32\">\n";
echo "Total visitor in this month :".$counter_month ."<p>Total visitor in this year :".$total_count."</div>";
?>
</div>
</body>
</html>