인기글 출력시 게시판 분류별로 인기글 뽑기 채택완료
latest_popular.lib.php
</strong><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><?php</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>if (!defined('_GNUBOARD_')) exit;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>// 인기글 추출</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>// $cache_time 캐시 갱신시간</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>function latest_popular($bo_table, $rows=10, $subject_len=40, $term='', $options='')</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>{</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> global $g5;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>switch($term){</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>case '일간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24); break;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>case '주간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*7); break;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>case '월간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*30); break;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>}</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $list = array();</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> if($bo_table){<span class="Apple-tab-span" style="white-space:pre"> </span>//각 게시판 출력</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $board = sql_fetch($sql);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $bo_subject = get_text($board['bo_subject']);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$sql_between = " wr_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and {$sql_between} order by {$options} limit 0, {$rows} ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $result = sql_query($sql);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> for ($i=0; $row = sql_fetch_array($result); $i++) {</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> }</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> }else{<span class="Apple-tab-span" style="white-space:pre"> </span>//전체 게시판 출력</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $sql_between = " a.bn_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $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} ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $sql_order = " order by a.bn_datetime desc ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $sql = " select a.*, count(b.bo_subject) as cnt {$sql_common} {$sql_order} limit 0, {$rows} ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> $row = sql_fetch($sql);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> if($row[cnt] > 0){</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$sql = " select a.*, b.bo_subject {$sql_common} {$sql_order} limit 0, {$rows} ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> $result = sql_query($sql);</b></span></font></p><p><span class="Apple-tab-span" style="white-space: pre; font-size: 12px; line-height: 21.6000003814697px;"><font face="돋움, dotum, helvetica"><b> </b></font></span></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> for ($i=0; $row = sql_fetch_array($result); $i++){</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$tmp_write_table = $g5['write_prefix'].$row['bo_table'];</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$bo_table = $row['bo_table'];</b></span></font></p><p><span class="Apple-tab-span" style="white-space: pre; font-size: 12px; line-height: 21.6000003814697px;"><font face="돋움, dotum, helvetica"><b> </b></font></span></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> if($i > 0)</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> $sql2 .= " union ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> $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."') ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> }</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$sql2 .= " order by ".$options." limit 0, 10";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$result2 = sql_query($sql2);</b></span></font></p><p><span class="Apple-tab-span" style="white-space: pre; font-size: 12px; line-height: 21.6000003814697px;"><font face="돋움, dotum, helvetica"><b> </b></font></span></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> for ($i=0; $row2 = sql_fetch_array($result2); $i++){</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> $list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> $list[$i]['subject'] = $row2['wr_subject'];</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> }</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span> }</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> }</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> ob_start();</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><? </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>$today = date("m-d"); </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>$todays = explode('-',$today);</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>$year = $todays[0]; //년도</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>$month = $todays[1];//달</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>$day = $todays[2];//일</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> </b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><div class="lt_full"></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><h2><span style="font-size:14px;">일간 조회수 랭킹</span></h2></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><div class="lt2"></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <ul></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <?php for ($i=0; $i<count($list); $i++) { ?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <li></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <?php</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo "<a href=\"".$list[$i]['href']."\">";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>echo "<img src='".G5_URL."/img/num_".($i+1).".gif' style='padding: 0 5px; float:left;'> ";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo "<nobr style=' float:left; display:block; overflow:hidden; width:90px;'>".$list[$i]['subject']."<nobr>";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo "<span style='color:#FF6600; padding-left:10px;'>".$list[$i]['wr_5']."</span>";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo "<span style='color:#FF6600; padding-right:12px; float:right;'>".$today."</span>";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> if ($list[$i]['comment_cnt'])</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo $list[$i]['comment_cnt'];</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> echo "</a>";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> ?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> </li></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <?php</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>if (($i+1)%($rows/2)==0) echo "</ul></div><div class='lt2'><ul>";</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>}</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <?php if (count($list) == 0) { //게시물이 없을 때 ?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <li>게시물이 없습니다.</li></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> <?php } ?></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> </ul></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b></div></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b></div></b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><?</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><span class="Apple-tab-span" style="white-space:pre"> </span>$content = ob_get_contents();</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> ob_end_clean();</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>
</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> return $content;</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>}</b></span></font></p><p><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b>?></b></span></font><strong style="font-family: 돋움, dotum, helvetica; font-size: 12px; line-height: 21.6000003814697px; background-color: rgb(255, 255, 255);">
위와같이 코드가 되어있는데
</strong><span style="font-family: 돋움, dotum, helvetica; font-size: 12px; font-weight: bold; line-height: 21.6000003814697px;"></span><span style="font-family: 돋움, dotum, helvetica; font-size: 12px; font-weight: bold; line-height: 21.6000003814697px;">function latest_popular($bo_table, $rows=10, $subject_len=40, $term='', $options=''</span><font face="돋움, dotum, helvetica"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b> , $category=''</b></span></font><span style="font-family: 돋움, dotum, helvetica; font-size: 12px; font-weight: bold; line-height: 21.6000003814697px;">)</span><strong style="font-family: 돋움, dotum, helvetica; font-size: 12px; line-height: 21.6000003814697px; background-color: rgb(255, 255, 255);">
이와같이 $category="" 를 맨뒤에 넣고
</strong><font face="돋움, dotum, helvetica" style="font-size: 10pt; line-height: 1.5;"><span style="font-size: 12px; line-height: 21.6000003814697px;"><b><?php echo latest_popular('VOD', 10, 40, '일간', 'wr_hit desc','영화'); //분류별 일간 조회수 ?></b></span></font><strong style="font-family: 돋움, dotum, helvetica; font-size: 12px; line-height: 21.6000003814697px; background-color: rgb(255, 255, 255);">
이렇게 출력하면 그냥 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} ";
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인