이 구문중에서 제가 잘못 쓴 구문이 있나요? 정보
이 구문중에서 제가 잘못 쓴 구문이 있나요?
본문
여기저기서 얻고 배운 소스로 공부중입니다.
지난 주 월요일부터 일요일까지 기간을 정해서 그 기간내에 게시글의 순위를 뽑으려고 합니다.
아래 소스처럼 배운 것과 얻은 것을 섞어서 해보았는데요..
출력이 아무것도 안되네요..
에러 메세지나 기타 다른 문구는 안나오는 걸로 봐서 문법상 틀리지는 않은 것 같은데.
왜 아무것도 안나오는지 잘 모르겠습니다.
혹시 php버전에 따라 strtotime 의 쓰임새가 다르거나 적용이 안되거나 하는 경우가 있나요?
고수님들 한번 봐주시고 무엇이 잘못됐는지 살펴주세요 ^^
====================================================================
$tomorrow = strtotime('+1 day');
$monday = date("Y-m-d",strtotime('-2 monday', $tomorrow));
$sunday = date("Y-m-d",strtotime('+6 day',$monday));
if ($skin_dir)
$skin_path = "$g4[path]/skin/top5/$skin_dir";
else
$skin_path = "$g4[path]/skin/top5/rank5";
$Writelist = array();
$Commentlist = array();
$Visitlist = array();
//글쓰기 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime between '$monday' and '$sunday' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id = a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 3 ";
$sql_order = " order by cnt desc ";
$sql = " SELECT b.mb_nick,count(*) cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0,$rows";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$Writelist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Writelist[$i][mb_cnt] = $row[cnt];
}
지난 주 월요일부터 일요일까지 기간을 정해서 그 기간내에 게시글의 순위를 뽑으려고 합니다.
아래 소스처럼 배운 것과 얻은 것을 섞어서 해보았는데요..
출력이 아무것도 안되네요..
에러 메세지나 기타 다른 문구는 안나오는 걸로 봐서 문법상 틀리지는 않은 것 같은데.
왜 아무것도 안나오는지 잘 모르겠습니다.
혹시 php버전에 따라 strtotime 의 쓰임새가 다르거나 적용이 안되거나 하는 경우가 있나요?
고수님들 한번 봐주시고 무엇이 잘못됐는지 살펴주세요 ^^
====================================================================
$tomorrow = strtotime('+1 day');
$monday = date("Y-m-d",strtotime('-2 monday', $tomorrow));
$sunday = date("Y-m-d",strtotime('+6 day',$monday));
if ($skin_dir)
$skin_path = "$g4[path]/skin/top5/$skin_dir";
else
$skin_path = "$g4[path]/skin/top5/rank5";
$Writelist = array();
$Commentlist = array();
$Visitlist = array();
//글쓰기 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime between '$monday' and '$sunday' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id = a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 3 ";
$sql_order = " order by cnt desc ";
$sql = " SELECT b.mb_nick,count(*) cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0,$rows";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$Writelist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Writelist[$i][mb_cnt] = $row[cnt];
}
댓글 전체
bn_datetime은 Y-m-d H:i:s 형태일텐데요???
청춘불안정님 번번히 답변 감사드립니다 ^^
Y-m-d는 알겠는데 Y-m-d H:i:s 은 어떻게 뽑아내야하는지를 모르겠습니다.
bn_datetime이 혹시 분 초 까지 써야하는 건가요?
bn_datetime에 맞춰 뽑아내려면 어떤 식으로 뽑는지 좀 배울 수 있을까요?
Y-m-d는 알겠는데 Y-m-d H:i:s 은 어떻게 뽑아내야하는지를 모르겠습니다.
bn_datetime이 혹시 분 초 까지 써야하는 건가요?
bn_datetime에 맞춰 뽑아내려면 어떤 식으로 뽑는지 좀 배울 수 있을까요?
$monday = date("Y-m-d H:i:s",strtotime('-2 monday', $tomorrow));
$sunday = date("Y-m-d H:i:s",strtotime('+6 day',$monday));
하시면 되겠지요~~
$sunday = date("Y-m-d H:i:s",strtotime('+6 day',$monday));
하시면 되겠지요~~
국방부장관님 답변 감사드립니다 ^^
근데 역시 그렇게 해도 적용이 안돼네요..
함수에서 잘못된 것이 아니라 소스에서 잘못된거 아닌가 싶습니다.
제가 보기엔 아무 문제 없는 것 같은데 도저히 못찾겠네요..
아래 소스에서 $startYmd 과 $nowYmd 사이의 값을 구해서 출력하면
제대로 출력이 되는데요..
이상하게 위의 함수로 바꿔서 하면 안되네요..
뭐가 잘못된 것인지..쩝..
===================================================================
$year = date("Y");
$month = date("m");
$day = date("d");
$tmp = mktime(0, 0, 0, $month, $day - 10 , $year, 0);
$startYmd = date("Y-m-d",$tmp);
$nowYmd = date(Ymd);
if ($skin_dir)
$skin_path = "$g4[path]/skin/top5/$skin_dir";
else
$skin_path = "$g4[path]/skin/top5/rank5";
$Writelist = array();
$Commentlist = array();
$Visitlist = array();
//글쓰기 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime between '$startYmd' and '$nowYmd' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id = a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 3 ";
$sql_order = " order by cnt desc ";
$sql = " SELECT b.mb_nick,count(*) cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0,$rows";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$Writelist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Writelist[$i][mb_cnt] = $row[cnt];
}
근데 역시 그렇게 해도 적용이 안돼네요..
함수에서 잘못된 것이 아니라 소스에서 잘못된거 아닌가 싶습니다.
제가 보기엔 아무 문제 없는 것 같은데 도저히 못찾겠네요..
아래 소스에서 $startYmd 과 $nowYmd 사이의 값을 구해서 출력하면
제대로 출력이 되는데요..
이상하게 위의 함수로 바꿔서 하면 안되네요..
뭐가 잘못된 것인지..쩝..
===================================================================
$year = date("Y");
$month = date("m");
$day = date("d");
$tmp = mktime(0, 0, 0, $month, $day - 10 , $year, 0);
$startYmd = date("Y-m-d",$tmp);
$nowYmd = date(Ymd);
if ($skin_dir)
$skin_path = "$g4[path]/skin/top5/$skin_dir";
else
$skin_path = "$g4[path]/skin/top5/rank5";
$Writelist = array();
$Commentlist = array();
$Visitlist = array();
//글쓰기 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime between '$startYmd' and '$nowYmd' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id = a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 3 ";
$sql_order = " order by cnt desc ";
$sql = " SELECT b.mb_nick,count(*) cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0,$rows";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$Writelist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Writelist[$i][mb_cnt] = $row[cnt];
}
mysql> SELECT a.mb_id, b.mb_nick,count(*) cnt from g4_board_new a inner join g4_member b on a.mb_id=b.mb_id where a.bn_datetime >=curdate()-interval ( dayofweek( curdate())+5) day and a.bn_datetime < curdate()-interval ( dayofweek( curdate())-2) day and a.wr_id=a.wr_parent and b.mb_level < 3 group by a.mb_id order by cnt desc ;
+----------+---------+-----+
| mb_id | mb_nick | cnt |
+----------+---------+-----+
| h**** | | 3 |
| lgc*** | | 2 |
| m**** | | 1 |
| c**** | | 1 |
| l**** | | 1 |
+----------+---------+-----+
5 rows in set (0.00 sec)
mysql> select curdate()-interval ( dayofweek( curdate())+5) day, curdate()-interval ( dayofweek( curdate())-2) day;
+---------------------------------------------------+---------------------------------------------------+
| curdate()-interval ( dayofweek( curdate())+5) day | curdate()-interval ( dayofweek( curdate())-2) day |
+---------------------------------------------------+---------------------------------------------------+
| 2009-01-26 | 2009-02-02 |
+---------------------------------------------------+---------------------------------------------------+
1 row in set (0.00 sec)
+----------+---------+-----+
| mb_id | mb_nick | cnt |
+----------+---------+-----+
| h**** | | 3 |
| lgc*** | | 2 |
| m**** | | 1 |
| c**** | | 1 |
| l**** | | 1 |
+----------+---------+-----+
5 rows in set (0.00 sec)
mysql> select curdate()-interval ( dayofweek( curdate())+5) day, curdate()-interval ( dayofweek( curdate())-2) day;
+---------------------------------------------------+---------------------------------------------------+
| curdate()-interval ( dayofweek( curdate())+5) day | curdate()-interval ( dayofweek( curdate())-2) day |
+---------------------------------------------------+---------------------------------------------------+
| 2009-01-26 | 2009-02-02 |
+---------------------------------------------------+---------------------------------------------------+
1 row in set (0.00 sec)
엑스엠엘님 감사합니다.
근데 제가 구문에는 잼뱅이라서 사실 이해가 많이 안됩니다..ㅎㅎ
조금 더 공부를 해야겠습니다..
함수와 구문의 길은 멀고도 험하네요..흑~
근데 제가 구문에는 잼뱅이라서 사실 이해가 많이 안됩니다..ㅎㅎ
조금 더 공부를 해야겠습니다..
함수와 구문의 길은 멀고도 험하네요..흑~