최신글 질문 드립니다
본문
안뇽하세요
<?php
$this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
$today_date = strtotime(date("Y-m-d"));
if ($this_date <= $today_date) {
$now_dday = 'TODAY';
} else {
$now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
}
echo $now_dday;
?>
여분필드wr_1에 시작일을 집어넣고 wr_2에 종료일을 집어넣어서
위처럼 디데이 게시물을 불러오고있습니다.
그런데 디데이가 지난 최신글은 안나오도록 없애버리고 싶은데 소스도 줍줍한거라
막막합니다 ㅠ_ㅜ 도움좀 부탁드립니다ㅜ
!-->답변 3
전체적인 소스를 확인하지 않아서 잘은 모르겠으나 올려주신 내용만으로 보면 아래처럼 처리하면될꺼 같습니다.
<?php
$this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
$today_date = strtotime(date("Y-m-d"));
if ($this_date <= $today_date) {
// $now_dday = 'TODAY'; <-- 이부분만 주석처리하면될꺼 같습니다.
} else {
$now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
}
echo $now_dday;
?>
요렇게 한번 주석처리 해보시고 돌려보시고 피드백은 한번 올려주세요
!-->가장 효율적인 것은
query문을 바꾸는 거죠.
어떤 파일에서 작업하시는 건가요?
echo $now_dday;
->
if ($list[$i]['wr_1'] > date('Y-m-d'))
continue;
echo $now_dday;
답변을 작성하시기 전에 로그인 해주세요.