채택완료

일요일이라면

2020-11-14 (토) 15:59:04 1,563

그런데 일요일에는 돌아가지 않게 하고 싶은데

이번주 일요일을 뽑는거 찾아보니 

if(!$setdate)$setdate = date("Y-m-d");
$today = strtotime($setdate);

echo '<br />이번주 일요일 : '.$sun = date('Y-m-d', (strtotime('SUNDAY', $today) > $today) ? strtotime('LAST SUNDAY', $today) : strtotime('SUNDAY', $today));    // 이번주 일요일

이렇게 하니 

  • 이번주 일요일 : 2020-11-08 이렇게 뽑히는군요

이제 오늘이 일요일이라면

$today_search .= " and SUBSTR(wr_datetime,1,10)=CURDATE() "; //오늘 날짜만 보이기

sql_query("update g5_write_test set ca_name = '완료' where mb_id = 'admin' $today_search ORDER BY RAND() LIMIT 8"); //

위코드가 작동안하게 하려면 어떻게 해야 할까요?

고수님 도움을 기다려봅니다.

혹시 이렇게 해보면 될까요?

if(!$setdate)$setdate = date("Y-m-d");
$today = strtotime($setdate);

$sun = date('Y-m-d', (strtotime('SUNDAY', $today) > $today) ? strtotime('LAST SUNDAY', $today) : strtotime('SUNDAY', $today));  // 이번주 일요일

if(!$sun) {

 $today_search .= " and SUBSTR(wr_datetime,1,10)=CURDATE() "; //오늘 날짜만 보이기

 sql_query("update g5_write_test set ca_name = '완료' where mb_id = 'admin' $today_search ORDER BY RAND() LIMIT 8"); //

}

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트

if(!$sun) {

이 부분을 아래와 같이 수정하세요

if(date('w') != 0) {

오늘이 일요일이 아니라면..

아래 참조..

https://offbyone.tistory.com/38

답변에 대한 댓글 1개

2020-11-16 (월) 10:20:38
감사합니다. 해보겠씁니다.

답변을 작성하려면 로그인이 필요합니다.