2026, 새로운 도약을 시작합니다.

여러게시판의 최신글 추출중 null값 문의 채택완료

안녕하세요.

회원님께서 올려주신 latest_all 함수를 이용하여 게시판 두개의 최신글을 합쳐서 불러오려합니다.

news 와 visit 게시판 두개인데요

이중 news에는 예약게시글 기능이있어 wr_2 값에 게시날짜를 넣어두었습니다.

아래 코드를 실행시 news부분에서 해당날짜가 안되는 값들이 나중에 list에서 null값으로 나옵니다..

null값을 빼고 나오는 방법이 따로 있을까요?./.

Copy



// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)

function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='')

{

    global $g5;

    if (!$skin_dir) $skin_dir = 'basic';

    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {

        if (G5_IS_MOBILE) {

            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            if(!is_dir($latest_skin_path))

                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);

        } else {

            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);

        }

        $skin_dir = $match[1];

    } else {

        if(G5_IS_MOBILE) {

            $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;

            $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;

        } else {

            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;

            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;

        }

    }
 

        $list = array();

        $sql_common = " from {$g5['board_new_table']} a  where find_in_set(a.bo_table, '{$bo_tables}')";

        $sql_common .= " and a.wr_id = a.wr_parent ";

        $sql_order = " order by a.bn_id desc ";

        $sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";

        $result = sql_query($sql);

        for ($i=0; $row=sql_fetch_array($result); $i++) {

            $sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";

            $board = sql_fetch($sql);

            $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];

            if(substr($tmp_write_table,9,4) == 'news'){

                $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' and date_format(now(), '%Y%m%d %H:%i') > REPLACE( wr_2, '-', '') ");

            }else if(substr($tmp_write_table,9,4) == 'visit'){

                $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");

            }else {

                $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");

            }

            $list[$i] = $row2;

            $list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);

            $list[$i]['bo_subject'] = $row['bo_subject'];

            $list[$i]['bo_table'] = $row['bo_table'];

        }

        

    ob_start();

    include $latest_skin_path.'/latest.skin.php';

    $content = ob_get_contents();

    ob_end_clean();
 

    return $content;

}


 

답변 1개

채택된 답변
+20 포인트

news 쿼리에 추가해보세요.

and wr_2 is not null

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

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

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

로그인
🐛 버그신고