간단한 카운트 > PHP

본문 바로가기
사이트 내 전체검색

PHP

간단한 카운트

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 5,046회 작성일 21-02-09 11:43

본문

############# 카운트 시작 ###########################
 $today = date("Y-m-d");
 $n_time = (int)trim(date("H"));
 // 쿠키보관시간
$tm = time() + 3600;
 $CntID = "특정단어";

if(!$HTTP_COOKIE_VARS["OneClick_Count"] || $HTTP_COOKIE_VARS["OneClick_Count"] != "$CntID"){
    SetCookie("OneClick_Count","$CntID",$tm,"/");
    $CoSQL = "select count(idx) from table_name where CntID = '$CntID' and n_date = '$today'";
    $CoRow = mysql_fetch_row(mysql_query($CoSQL));
    if(!$CoRow[0] || $CoRow[0] < 1){
      $CoSQL = "insert into  table_name (CntID, n_date";
      for($i=0; $i <= 23; $i++){
            $CoSQL .= ", H{$i}";
      }
      $CoSQL .= ", n_total) values ('$CntID', '$today'";
      for($i=0; $i <= 23; $i++){
          if($i == $n_time){
            $CoSQL .= ",'1'";
          }else{
            $CoSQL .= ",'0'";
          }
      }
      $CoSQL .= ",'1')";
    }else{
      $CoSQL = "update  table_name set H".$n_time." = H".$n_time."+1, n_total = n_total+1 where CntID = '$CntID' and n_date = '$today'";
    }
    mysql_query($CoSQL);
 } 
 ############# 카운트 끝 ###########################

CREATE TABLE ` table_name` (
  `idx` int(11) NOT NULL auto_increment,
  `CntID` varchar(25) NOT NULL default '',
  `n_date` varchar(11) default NULL,
  `H0` int(11) default NULL,
  `H1` int(11) default NULL,
  `H2` int(11) default NULL,
  `H3` int(11) default NULL,
  `H4` int(11) default NULL,
  `H5` int(11) default NULL,
  `H6` int(11) default NULL,
  `H7` int(11) default NULL,
  `H8` int(11) default NULL,
  `H9` int(11) default NULL,
  `H10` int(11) default NULL,
  `H11` int(11) default NULL,
  `H12` int(11) default NULL,
  `H13` int(11) default NULL,
  `H14` int(11) default NULL,
  `H15` int(11) default NULL,
  `H16` int(11) default NULL,
  `H17` int(11) default NULL,
  `H18` int(11) default NULL,
  `H19` int(11) default NULL,
  `H20` int(11) default NULL,
  `H21` int(11) default NULL,
  `H22` int(11) default NULL,
  `H23` int(11) default NULL,
  `n_total` int(11) default NULL,
  PRIMARY KEY  (`idx`)
 ) ;

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
4,381
어제
4,449
최대
6,642
전체
885,943
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.