$query = mysql_query("select * from $counter");
$row = mysql_fetch_array($query);
$total = $row[total];
$today = $row[today];
$yesterday = $row[yesterday];
$max = $row[max];
$date = $row[date];
$time = $row[time];
$nowdate = date("Y-m-d");
$nowtime = time();
if ($nowdate == $date){
$total = $total + 1;
$today = $today + 1;
}elseif ($nowdate != $date){
if (date("Y-m-d", time(0, 0, 0, date("m"), date("d")-1, date("Y"))) == $date) {
$total = $total + 1;
$yesterday = $today;
$today = 1;
}else{
$total = $total + 1;
$today = 1;
}}
if ($total < $today) { $total = $today; }
if ($yesterday > $max) { $max = $yesterday; }
$counterchk_qry=mysql_query("select * from $counter");
if(!mysql_num_rows($counterchk_qry)){
mysql_query("insert into $counter value ('','$total','$today','$yesterday','$max','$nowdate','$nowtime')");
}else{
mysql_query("update $counter set total='$total', today='$today', yesterday='$yesterday', max='$max', date='$nowdate', time='$nowtime'");
}
echo("$total");
?>
|