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

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

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

선배님들 도와주세요.

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

답변 1개

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

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

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

답변에 대한 댓글 4개

order by wr_comment DESC 이건 그냥 댓글 역순으로 뽑는 거 같네요. 저는 최근에 댓글이 많이 달린 게시글을 뽑고 싶습니다.
db에서 wr_comment가 코멘트 수입니다. 그래서 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
}
?>

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

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

로그인

전체 질문 목록

🐛 버그신고