그룹게시판의 인기글만 뽑는 코드를 만드려고 하는데 에러가 발생하내요?
본문
스킨에 있는 인기글 게시판을 조금 수정해서 그룹 게시판 인기글을 뽑는 코드를 만드려는데요.
메뉴1($gr_id)를 누르면 그안에 있는 게시판($bo_table) 들의 조회수 추천수를 많은수 인기순으로 뽑아서 보여주려고 하는데요. 이런 에러가 발생하는데
select * from g5_write_ where wr_is_comment = 0 and wr_datetime between '2015-04-09 04:42:20' and '2015-04-10 04:42:20' order by wr_hit desc limit 0, 10
1146 : Table 'shintest.g5_write_' doesn't exist
error file : /gnuboard5.0.30/bbs/group.php
db에 g5_write_ 부분이 없다고 하는거 같은데요.
이렇게 코드를 짜면 될줄 알았는데 어떤 방식이 잘 못 된거죠? ㅠㅠ
혹시 코드 보시고 어디가 잘못 됬거나 어떻게 하면 되는지 도움이나 팁을 주시면 감사하겠습니다.
혼자서 해보려고 하니까 쉬운게 하나 없네요ㅠㅠ
저 코드는 bbs\group.php 여기서 include_once('./_head.php');?> 부분 다음에
<?php include_once(G5_LIB_PATH.'/latest_popular2.lib.php'); ?> 넣었습니다.
<?php
if (!defined('_GNUBOARD_')) exit;
function latest_popular2($gr_id, $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($gr_id) //각 게시판 출력
{
$sql = " select * from {$g5['board_table']} where gr_id = '{$gr_id}' ";
$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);
}
}
ob_start();
?>
<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
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;
}
?>
답변 2
$bo_table 이값이 넘어오는 변수가 없는거 같은데....
$tmp_write_table
=
$g5
[
'write_prefix'
] .
$bo_table
;
이부분을
$tmp_write_table
=
$g5
[
'write_prefix'
] . $board['
bo_table']
;
이렇게 한번 해보시져..
if($gr_id) //각 게시판 출력
{
$sql = " select * from {$g5['board_table']} where gr_id = '{$gr_id}' ";
$group = sql_query($sql);
for ($b=0; $board = sql_fetch_array($group); $b++)
$bo_subject = get_text($board['bo_subject']);
$tmp_write_table = $g5['write_prefix'] . $board[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);
}
}
}
위와 같이 해보세요.
그룹별로 게시판 정보를 가져와서 루프로 돌리면서 1행씩 가져오셔야합니다.
테스트 해보니는 못했습니다.
아마도 오류가 발생할테니 적당히 수정해서 쓰세요.
!-->