Old/PHP
하루전, 하루후 등 게시물 검색하기
yundev
2013. 7. 5. 17:42
반응형
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; }
반응형