특정기간 동안 전체글에서 댓글 많은 게시물만 추출하려면 어떻게 해야할까요?

특정기간 동안 전체글에서 댓글 많은 게시물만 추출하려면 어떻게 해야할까요?

QA

특정기간 동안 전체글에서 댓글 많은 게시물만 추출하려면 어떻게 해야할까요?

답변 1

본문

댓글 많은 순으로 보여주는 함수는 공개 된게 없네요..

선배님들 도와주세요.

이 질문에 댓글 쓰기 :

답변 1

sql 정렬을 'order by wr_comment DESC' 로 하시면 됩니다.

대신 where에 wr_is_comment = '0'이 들어가 있어야 원문만 불러오겠죠.

<?php
include "_common.php";
//define('_INDEX_', true);
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

$board_sql = 'select bo_table from '. $g5['board_table'];
$board_query = sql_query($board_sql);
$board_column = 'wr_subject, wr_hit, wr_comment, wr_is_comment';
$tabAll_limit = 10; //최대순위

//각 게시판 테이블명 뽑아내기
while( $board_fetch = sql_fetch_array($board_query) ) {
$bo_table = $board_fetch['bo_table'];

if(!$tabAllBoard['query']) {
$tabAllBoard['query'] = '(select '. $board_column .' from g5_write_'. $bo_table .')';
} else {
$tabAllBoard['query'] .= ' union all (select '. $board_column .' from g5_write_'. $bo_table .')';
}
}

$tabAllQuery = 'select '. $board_column .' from ('. $tabAllBoard['query'] .') where wr_is_comment = 0 order by wr_comment DESC limit '. $tabAll_limit;
$tabAllResult = sql_query($tabAllQuery);
$i=1;
while( $tabAll = sql_fetch_array($tabAllResult) ) {
?>
<li class="h_icon0<?=$i++?>"><a href="<?=$g5['bbs_path']?>/board.php?bo_table="><?=$tabAll['wr_subject']?></a><?=$tabAll['wr_hit']?></li>
<?php
}
?>

답변을 작성하시기 전에 로그인 해주세요.
전체 3
© SIRSOFT
현재 페이지 제일 처음으로