조회수순, 추천순 관련 문의..
본문
아래 코드는 댓글많은 순인데 조회수나, 추천 많은 순으로 나오게 하려면 어떻게 해야하나요?ㅠ
<?php
if (!defined('_GNUBOARD_')) exit;
// 인기글 추출
// $cache_time 캐시 갱신시간
function latest_popular($bo_table, $rows=10, $subject_len=40, $term='', $options='')
{
global $g5;
switch($term){
case '일간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24); break;
case '주간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*7); break;
case '월간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*30); break;
}
$list = array();
if($bo_table){ //각 게시판 출력
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
$board = sql_fetch($sql);
$bo_subject = get_text($board['bo_subject']);
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$sql_between = " wr_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_comment desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
}
}else{ //전체 게시판 출력
$sql_between = " a.bn_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";
$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b where a.bo_table = b.bo_table and b.bo_use_search = 1 and a.wr_id = a.wr_parent and {$sql_between} ";
$sql_order = " order by a.bn_datetime desc ";
$sql = " select count(b.bo_subject) as cnt {$sql_common} {$sql_order} limit 0, {$rows} ";
$row = sql_fetch($sql);
if($row['cnt'] > 0){
$sql = " select a.*, b.bo_subject {$sql_common} {$sql_order} limit 0, {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++){
$tmp_write_table = $g5['write_prefix'].$row['bo_table'];
$bo_table = $row['bo_table'];
if($i > 0) $sql2 .= " union ";
$sql2 .= "(select *, '{$bo_table}' as bo_table from {$tmp_write_table} where wr_datetime between '{$term_time}' and '".G5_TIME_YMDHIS."') ";
}
//$sql2 .= " order by ".$options." limit 0, 10";
$sql2 .= " limit 0, $rows";
//echo $sql2;
$result2 = sql_query($sql2);
for ($i=0; $row2 = sql_fetch_array($result2); $i++){
$list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];
$list[$i]['subject'] = $row2['wr_subject'];
if($row2['wr_comment'])
$list[$i]['comment_cnt'] = "<span class=\"cnt_cmt\">".$row2['wr_comment']."</span>";
}
}
}
ob_start();
?>
<style type=text/css>
.lt_full {position:relative;float:left;padding-bottom:10px;width:100%;height:210px; background:#ffffff;}
.lt2 {position:relative;float:left;padding-bottom:0px;width:100%;background:#ffffff;padding:0;margin:10px 0 0 0px;}
.lt2 li {padding:0}
</style>
<div class="lt_full">
<div class="lt2">
<ul>
<?php for ($i=0; $i<count($list); $i++) { ?>
<li>
<?php
echo "<a href=\"".$list[$i]['href']."\">";
echo "<img src='".G5_URL."/img/num_".($i+1).".gif'> ";
echo "<strong>".$list[$i]['subject']."</strong>";
if ($list[$i]['comment_cnt'])
echo $list[$i]['comment_cnt'];
echo "</a>";
?>
</li>
<?php
}
?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
<li>게시물이 없습니다.</li>
<?php } ?>
</ul>
</div>
</div>
<?
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
<style>
.tab_list ul{ }
.tab_list ul:after{ }
.tab_list li{ }
.tab_list li a{ }
.tab_list li a span{ }
.tab_list li ul{ }
.tab_list li li{padding-bottom:9px;padding-top:7px;border-bottom:1px solid #e9ecf3;}
.tab_list li li a{padding:0 0 0 15px;}
.tab_list li li img {vertical-align:bottom;padding-top:1px;margin-bottom:5px;}
.tab_list li li strong{vertical-align:top;font-size:14px}
.tab_list.m1 .m1 a,
.tab_list.m2 .m2 a,
.tab_list.m3 .m3 a,
.tab_list.m4 .m4 a,
.tab_list.m5 .m5 a { }
.tab_list.m1 .m1 a span,
.tab_list.m2 .m2 a span,
.tab_list.m3 .m3 a span,
.tab_list.m4 .m4 a span,
.tab_list.m5 .m5 a span{color:#225ac6;font-size:12px;font-weight:600;padding:0 10px;margin:0px 5px;border:1px solid #e9ecf3;border-radius:5px;}
.tab_list.m1 .m1 ul,
.tab_list.m2 .m2 ul,
.tab_list.m3 .m3 ul,
.tab_list.m4 .m4 ul,
.tab_list.m5 .m5 ul{background:#ffffff; }
strong{font-size:1.083em;}
.tab_list strong{font-size:14px;font-weight:400;}
</style>
<div style="width:100%; height:10px;background-color: #e9ecf3;">
</div>
<div style="height:<? if($bo_table) echo"170"; else echo"220"; ?>px" class="tab_list m1">
<ul>
<!-- 게시판제목불러오기-->
<div style="
font-weight:900; font-size:16px; padding:2px 15px; padding-top:16px; background:#ffffff;
">댓글많은 글
</div>
<li class="m1">
<ul>
<li><?php echo latest_popular($bo_table, 5, 40, '일간', 'wr_datetime desc'); ?></li>
</ul>
</li>
</ul>
</div>
<script type="text/javascript">
/* jQuery(function($){
var tab = $('.tab_list');
tab.removeClass('js_off');
tab.css('height', tab.find('>ul>li>ul:visible').height()+40);
function onSelectTab(){
var t = $(this);
var myClass = t.parent('li').attr('class');
t.parents('.tab_list:first').attr('class', 'tab_list '+myClass);
tab.css('height', t.next('ul').height()+40);
}
tab.find('>ul>li>a').click(onSelectTab).focus(onSelectTab);
}); */
</script>
<div style='height:15px;'></div>
<div style="width:100%; height:10px;background-color: #e9ecf3;">
</div>
아래는 호출 코드입니다
<?php $bo_table = "best"; ?>
<?php include_once(G5_LIB_PATH.'/latest_popular.lib.php'); ?>
답변을 작성하시기 전에 로그인 해주세요.