사이트 내 전체검색
PHP
mktime() 하루전, 하루후 등 게시물 검색하기
로빈아빠
https://cmd.kr/php/329 URL이 복사되었습니다.

본문

mktime() 하루전, 하루후 등 게시물 검색하기

 $yday   = date("m-d-Y",strtotime("-1 day", time()));
 $yday   = split("-", $yday);
 $ydays  = mktime(0,0,0,$yday[0],$yday[1],$yday[2]);


*.전체 참여자 수 계산

function all_record_cnt($tbname){
 $sql    = "select count(*) from $tbname";
 $result = mysql_query($sql);
 $cnt    = mysql_result($result, 0, 0);
 return $cnt;
}

*.어제 참여자 수 계산
function yday_record_cnt($tbname){
 $yday   = date("m-d-Y",strtotime("-1 day", time()));
 $yday   = split("-", $yday);
 $ydays  = mktime(0,0,0,$yday[0],$yday[1],$yday[2]);
 $ydaye  = mktime(23,59,59,$yday[0],$yday[1],$yday[2]);
 $sql    = "select count(*) from $tbname ";
 $sql   .= "where write_day>='$ydays' and write_day<='$ydaye'";
 $result = mysql_query($sql);
 $cnt    = mysql_result($result, 0, 0);
 return $cnt;
}

*.오늘 참여자 수 계산
function tday_record_cnt($tbname){
 $tday   = date("m-d-Y");
 $tday   = split("-", $tday);
 $tdays  = mktime(0,0,0,$tday[0],$tday[1],$tday[2]);
 $tdaye  = mktime(23,59,59,$tday[0],$tday[1],$tday[2]);
 $sql    = "select count(*) from $tbname ";
 $sql   .= "where write_day>='$tdays' and write_day<='$tdaye'";
 $result = mysql_query($sql);
 $cnt    = mysql_result($result, 0, 0);
 return $cnt;
}

댓글목록

등록된 댓글이 없습니다.

PHP
871 (6/18P)

Search

Copyright © Cmd 명령어 3.144.211.45