<div class="left_visited">
   <div class="visited">
     <h4>最近访客</h4>
	   <?php
	       //查询访客记录
		   $query = mysql_query("select * from {$total_pr}visited where userid='".$_SESSION['user_id']."' order by id desc");
		   $row = mysql_fetch_array($query);
		   if($row == false){
			   echo '<div class="no_visited">还没有访客到此一游^_^</div>';
		   }
		   else{
			do{
			
			 //获取访客到此和此刻的月份及时间戳
			 $time = date("Y",strtotime($row['time']));
			 $now_time = date("Y",time());
			 //判断是否为同年同月
			 if($time == $now_time){
				 //获取月
				 $mtime = date("m",strtotime($row['time']));
				 $mnow_time = date("m",time());
				 if($mtime == $mnow_time){
				   //获取天
				   $dtime = date("d",strtotime($row['time']));
				   $dnow_time = date("d",time());
				   $date = $dnow_time - $dtime;
				   //判断访客到此为哪天
				   switch($date){
					   case 0:
							$v_time = "今天";
						 break;
					   case 1:
							$v_time = "昨天";
						 break;
					   case 2:
							$v_time = "前天";
						 break;
					   default:
					        $v_time = "这个月";
				   }
				 }
				 elseif($mnow_time - $mtime == 1){
				    $v_time = "上个月";	 
				 }
				 else{
				    $v_time = "今年";	 
				 }
			 }
			 else {
			     $v_time = "以前";	 
			 }
			 
			 
			 
			 
        ?>
        <div class="user">
           <img src="<?=$row['visitor_img'] ?>" />
           <div class="user_name"><a href="index.php?id=<?php echo $row['visitorid'] ?>">
           <?php
              echo substr($row['visitor_name'],0,5); 
              if(strlen($row['visitor_name'] > 5)){
                  echo "..";
              }
           ?>
             </a>
           </div>
           <div class="user_time">
             <?php echo $v_time ?>
           </div>
        </div>
        <?php
          }
          while($row = mysql_fetch_array($query));
         }
        ?>
    </div>
    <div class="visited_status">
      <?php
	   $query = mysql_query("select id from {$total_pr}visited where userid='".$_SESSION['user_id']."'");
	   $num = mysql_num_rows($query);
	   $time = date("Y-m-d");
	   $query = mysql_query("select id from {$total_pr}visited where userid='".$_SESSION['user_id']."' and time='".$time."'");
	   $now_num = mysql_num_rows($query); 
	  ?>
      <div class="visited_num">总访问量：<span class="num"><?=$num ?></span></div>
      <div class="visited_num">今日访问：<span class="num"><?=$now_num ?></span></div>
    </div>
</div>