테스트 사이트 - 개발 중인 베타 버전입니다

wr_datetime 채택완료

마이트 10년 전 조회 3,600

wr_datetime에서

1.금년도 쓴글을 추출하는 소스랑

2.전년도 이전에 쓴글을 추출하는 소스랑 어떻게 되나요?

latast를 두가지로 수정해서 게시판을 추출하려고 합니다.

방법을 알려주세요

</strong></p><p>function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
} 
    global $g4;</p><p>    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";</p><p>    $list = array();</p><p>    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);</p><p>    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체お名前
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++) 
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
    
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();</p><p>    return $content;
} ​</p><p><strong>

 

 

 

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

답변 6개

채택된 답변
+20 포인트
10년 전

</p><p><b>$yearcheck = substr(G5_TIME_YMDHIS, 0, 4)​;</b></p><p>
$sql = " select * from $tmp_write_table where wr_is_comment = 0 <b>and wr_datetime > $yearcheck​​</b> order by wr_num limit 0, $rows ";</p><p>//올해</p><p>
$sql = " select * from $tmp_write_table where wr_is_comment = 0 <b>and wr_datetime < $yearcheck​​ ​</b> order by wr_num limit 0, $rows ";</p><p>//올해 이전</p><p>

 

위와 같이 서버시간의 년도값만 빼내서 글의 시간을 비교하면 될거 같네요.​ 

로그인 후 평가할 수 있습니다

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

10년 전

substr(wr_datetime,1,4)​이게 원인이이네요

sql문이랑 php랑틀렸던가요? 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

야레야렐
10년 전
sql 문에서 저걸 바로 쓸수는 없습니다.

따로 select로 wr_datetime 값을 불러와서 변수로 지정해서 쓰거나 해야합니다.

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

10년 전

일단 $chktime​ 부분을

 

'2015' 이런식으로 직접 숫자를 넣어서 결과값이 나오나 확인해보세요.

 

된다면 substr로 붙어서 넣는게 안되는 이유가 있을거고.

 

안된다면 다른 이유가 있겠죠

 

 

로그인 후 평가할 수 있습니다

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

10년 전

그건 잘나오는데요

sql문에 substr(wr_datetime,0,4)이렇게 들어갈수있나요?

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

야레야렐
10년 전
wr_datetime 값이 있다면 되지 않을까 싶네요.

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

10년 전

그런데 결과가 안나오니 어떻게 된건지...

sql문에 substr(wr_datetime,0,4)이렇게 들어갈수있나요?

아래처럼 물론 출력결과가 안나오지만

$sql = " select * from $tmp_write_table where wr_is_comment = 0 and substr(wr_datetime,0,4) = substr(DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s'),0,4) order by wr_num limit 0, $rows "

</b>​</p><p>function this_year($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
    global $g4;</p><p>    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";</p><p>    $list = array();
 
  
    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);</p><p>    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체お名前
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
 //$yearcheck = substr($g4[time_ymd], 0, 4)​;
 
 
 $chktime = substr($g4[time_ymdhis], 0, 4);
 
 //DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s')
 
 //$sql = " select * from $tmp_write_table where wr_is_comment = 0 and substr(wr_datetime,0,4) = substr(DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s'),0,4) order by wr_num limit 0, $rows "; 
 $sql = " select * from $tmp_write_table where wr_is_comment = 0 and wr_datetime > $chktime ​ order by wr_num limit 0, $rows "; 
 
 
   // $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++) 
        //echo $row[wr_datetime];
  //echo  substr($row[wr_datetime],0,4);
  
  
  $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
  
  
    
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();</p><p>    return $content;
} ​</p><p><b>
​ ​ 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

야레야렐
10년 전
return substr($g4[time_ymdhis], 0, 4);

으로 값이 나오는지 체크 한번 해보세요.

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

10년 전
wr_datetime 값이랑 $chktime ​이 비교가 가능한가요?​

[code]

function this_year($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="") {     global $g4;

    if ($skin_dir)         $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";     else         $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();          $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";     $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; 

$chktime = substr($g4[time_ymdhis], 0, 4);    $sql = " select * from $tmp_write_table where wr_is_comment = 0 and wr_datetime > $chktime ​order by wr_num limit 0, $rows ";          $result = sql_query($sql);     for ($i=0; $row = sql_fetch_array($result); $i++)         $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);         ob_start();     include "$latest_skin_path/latest.skin.php";     $content = ob_get_contents();     ob_end_clean();

    return $content; } ​

[/code] ​ 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

야레야렐
10년 전
비교 가능합니다.

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

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

로그인