[php]<?PHP
$con=mysql_connect("localhost","userdatabase","pas sword");
mysql_select_db("database",$con);
// m2
$result=mysql_query("SELECT * FROM counter");
$row=mysql_fetch_array($result);
$total=$row['total'];
$yesterday=$row['yesterday'];
$today=$row['today'];
$date=$row['date'];
@list($year,$month,$day)=split('-',$date);
// m3
$CurrentDate=date("Y-m-d");
@list($CurrentYear,$CurrentMonth,$CurrentDay) = split ('-',$CurrentDate);
//$total=0;
// m4
function Update($today,$yesterday,$total,$date){
mysql_query("UPDATE counter SET today='$today',yesterday='$yesterday',total='$tota l' ,date='$date' WHERE id=1");
}
// m5
$total++;
if($CurrentYear==$year){
if($CurrentMonth==$month){
if($CurrentDay==$day){
$today++;
Update($today,$yesterday,$total,$CurrentDate);
}else{
if($CurrentDay==++$day){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
}else{
if($CurrentMonth==++$month){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
}
else{
if($CurrentYear==++$year){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
// m6
$result=mysql_query("SELECT * FROM counter");
$row=mysql_fetch_array($result);
$total=$row['total'];
$yesterday=$row['yesterday'];
$today=$row['today'];
?>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td valign="top" bgcolor="d2d6d9"><table width="100%" border="0" class="matn">
<tr>
<td><div align="center"><?php echo $today; ?></div></td>
<td><div align="center">بازدید امروز </div></td>
</tr>
<tr>
<td><div align="center"><?php echo $yesterday; ?></div></td>
<td><div align="center">بازدید دیروز </div></td>
</tr>
<tr>
<td><div align="center"><?php echo $total; ?></div></td>
<td><div align="center">کل بازدیدها </div></td>
</tr>
</table></td>
</tr>
</table>[/php]
$con=mysql_connect("localhost","userdatabase","pas sword");
mysql_select_db("database",$con);
// m2
$result=mysql_query("SELECT * FROM counter");
$row=mysql_fetch_array($result);
$total=$row['total'];
$yesterday=$row['yesterday'];
$today=$row['today'];
$date=$row['date'];
@list($year,$month,$day)=split('-',$date);
// m3
$CurrentDate=date("Y-m-d");
@list($CurrentYear,$CurrentMonth,$CurrentDay) = split ('-',$CurrentDate);
//$total=0;
// m4
function Update($today,$yesterday,$total,$date){
mysql_query("UPDATE counter SET today='$today',yesterday='$yesterday',total='$tota l' ,date='$date' WHERE id=1");
}
// m5
$total++;
if($CurrentYear==$year){
if($CurrentMonth==$month){
if($CurrentDay==$day){
$today++;
Update($today,$yesterday,$total,$CurrentDate);
}else{
if($CurrentDay==++$day){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
}else{
if($CurrentMonth==++$month){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
}
else{
if($CurrentYear==++$year){
$yesterday=$today;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
else{
$yesterday=0;
$today=1;
Update($today,$yesterday,$total,$CurrentDate);
}
}
// m6
$result=mysql_query("SELECT * FROM counter");
$row=mysql_fetch_array($result);
$total=$row['total'];
$yesterday=$row['yesterday'];
$today=$row['today'];
?>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td valign="top" bgcolor="d2d6d9"><table width="100%" border="0" class="matn">
<tr>
<td><div align="center"><?php echo $today; ?></div></td>
<td><div align="center">بازدید امروز </div></td>
</tr>
<tr>
<td><div align="center"><?php echo $yesterday; ?></div></td>
<td><div align="center">بازدید دیروز </div></td>
</tr>
<tr>
<td><div align="center"><?php echo $total; ?></div></td>
<td><div align="center">کل بازدیدها </div></td>
</tr>
</table></td>
</tr>
</table>[/php]