new.php 에서... 최근게시물만 추출하고 싶은데... > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

new.php 에서... 최근게시물만 추출하고 싶은데... 정보

new.php 에서... 최근게시물만 추출하고 싶은데...

본문

<?
include_once("./_common.php");

$g4[title] = "최근 게시물";
include_once("./_head.php");

$sql_common = " from $g4[board_new_table] a, $g4[board_table] b, $g4[group_table] c
              where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = '1' ";
if ($gr_id)
    $sql_common .= " and b.gr_id = '$gr_id' ";
if ($view == "w")
    $sql_common .= " and a.wr_id = a.wr_parent ";
if ($mb_id)
    $sql_common .= " and a.mb_id = '$mb_id' ";
$sql_order = " order by a.bn_id desc ";

$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);
$total_count = $row[cnt];

$rows = $config[cf_new_rows];
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$group_select = "<select name=gr_id id=gr_id onchange='select_change();'><option value=''>전체그룹";
$sql = " select gr_id, gr_subject from $g4[group_table] order by gr_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
    $group_select .= "<option value='$row[gr_id]'>$row[gr_subject]";
}
$group_select .= "</select>";


$list = array();
$sql = " select a.*, b.bo_subject
          $sql_common
          $sql_order
          limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
    $tmp_write_table = $g4[write_prefix] . $row[bo_table];

    if ($row[wr_id] == $row[wr_parent]) // 원글
    {

        $row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
        $list[$i] = $row2;

        $name = get_sideview($row2[mb_id], cut_str($row2[wr_name], $config[cf_cut_name]), $row2[wr_email], $row2[wr_homepage]);
        // 당일인 경우 시간으로 표시함
        $datetime = substr($row2[wr_datetime],0,10);
        $datetime2 = $row2[wr_datetime];
        if ($datetime == $g4[time_ymd])
            $datetime2 = substr($datetime2,11,5);
        else
            $datetime2 = substr($datetime2,5,5);

    }


    $list[$i][gr_id] = $row[gr_id];
    $list[$i][bo_table] = $row[bo_table];
    $list[$i][name] = $name;
    $list[$i][href] = "./board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
    $list[$i][datetime] = $datetime;
    $list[$i][datetime2] = $datetime2;

    $list[$i][gr_subject] = $row[gr_subject];
    $list[$i][bo_subject] = $row[bo_subject];
    $list[$i][wr_subject] = $row2[wr_subject];
}

$write_pages = get_paging($config[cf_write_pages], $page, $total_page, "?gr_id=$gr_id&view=$view&mb_id=$mb_id&page=");

$new_skin_path = "$g4[path]/skin/new/$config[cf_new_skin]";

echo "<script language=\"javascript\" src=\"$g4[path]/js/sideview.js\"></script>\n";

?>

<table width=345 cellpadding=0 cellspacing=0>
<tr>
    <td width='100%'>
<img src="../../images/newboard.gif" border="0">
</td>
</tr>
</table>

<table width=345 cellpadding=0 cellspacing=0 class="ttola_list_box">
<?
for ($i=0; $i<count($list); $i++)

    $gr_subject = cut_str($list[$i][gr_subject], 25);
    $bo_subject = cut_str($list[$i][bo_subject], 25);
    $wr_subject = get_text(cut_str($list[$i][wr_subject], 40));

    $list[$i][name] = strip_tags($list[$i][name]);
    $list[$i][num] = number_format($total_count - ($page - 1) * $rows - $i);

?>
<tr valign="top">
<td colspan=4 align=left class="ttola_list_margin">
<table width="100%">
<tr>
<td height="20px">
<img src='../skin/latest/notice/img/latest_icon.gif'>&nbsp;
<a href='./board.php?bo_table=<?=$list[$i][bo_table]?>' title='<?=$list[$i][bo_subject]?>'><font style='color:#CC9999;'><?=$bo_subject?></a>
    <a href='<?=$list[$i][href]?>' title='<?=$list[$i][wr_subject]?>'><?=$wr_subject?></a> <?=$list[$i][newicon]?></font>
    </td>

<td align="right"><span class='ttola_datetime'><?=$list[$i][datetime2]?></td>
</tr>
</table>
</td>
</tr>
<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=44><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
</table>


이미지첨부파일처럼...

최근게시물의 목록은 나오는데
최근코멘트의 게시판이 떠버리네요ㅠㅠ

고수님들 좀 봐주시면 고맙겠습니다.
감사합니다 (_ _)

댓글 전체

전체 66,558 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT