인기글 출력시 게시판 분류별로 인기글 뽑기
본문
latest_popular.lib.php
<?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 and {$sql_between} order by {$options} 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 a.*, 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, wr_id, wr_subject, wr_hit, wr_good from {$tmp_write_table} where wr_datetime between '{$term_time}' and '".G5_TIME_YMDHIS."') ";
}
$sql2 .= " order by ".$options." limit 0, 10";
$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'];
}
}
}
ob_start();
?>
<?
$today = date("m-d");
$todays = explode('-',$today);
$year = $todays[0]; //년도
$month = $todays[1];//달
$day = $todays[2];//일
?>
<div class="lt_full">
<h2><span style="font-size:14px;">일간 조회수 랭킹</span></h2>
<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' style='padding: 0 5px; float:left;'> ";
echo "<nobr style=' float:left; display:block; overflow:hidden; width:90px;'>".$list[$i]['subject']."<nobr>";
echo "<span style='color:#FF6600; padding-left:10px;'>".$list[$i]['wr_5']."</span>";
echo "<span style='color:#FF6600; padding-right:12px; float:right;'>".$today."</span>";
if ($list[$i]['comment_cnt'])
echo $list[$i]['comment_cnt'];
echo "</a>";
?>
</li>
<?php
if (($i+1)%($rows/2)==0) echo "</ul></div><div class='lt2'><ul>";
}
?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
<li>게시물이 없습니다.</li>
<?php } ?>
</ul>
</div>
</div>
<?
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
위와같이 코드가 되어있는데
function latest_popular($bo_table, $rows=10, $subject_len=40, $term='', $options='' , $category='')
이와같이 $category="" 를 맨뒤에 넣고
<?php echo latest_popular('VOD', 10, 40, '일간', 'wr_hit desc','영화'); //분류별 일간 조회수 ?>
이렇게 출력하면 그냥 VOD 전체 게시판에 대한 일간조회수가 나옵니다. 옵션뒤에 카테고리함수 분류별 (category)가 먹질 않습니다.
무엇이 문제인가요?
!-->!-->!-->
답변 1
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and {$sql_between} order by {$options} limit 0, {$rows} ";
여기를 아래처럼..
$sql = " select * from {$tmp_write_table} where ca_name = '{$category}' and {$sql_between} order by {$options} limit 0, {$rows} ";
답변을 작성하시기 전에 로그인 해주세요.