제발... 도움 부탁드립니다. > 그누4 질문답변

그누4 질문답변

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

제발... 도움 부탁드립니다. 정보

제발... 도움 부탁드립니다.

본문

두개의 게시판(공지사항,최신뉴스)에서 최신글을 보여주는 소스를 질문답변/팁 게시판을 검색해서 붙이는 것까지는 성공했는데..
최신글 5개만 보여주고 싶은데 등록된글이 계속해서 쭈욱~ 보여지네요.
어떤걸 수정해야할지 도움좀 부탁드립니다.
 
인덱스 페이지에 적용한 내용
///////////////////////////////////////////////
<?=latest_union("basic", "0701", "0604", 5, 40, "wr_hit"); ?>
 
 
최신글 스킨(latest.skin.php)  소스
//////////////////////////////////////////////
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<table width=100% cellpadding=0 cellspacing=0>
<colgroup width=14>
<colgroup>
<colgroup width=37>
<colgroup width=14>
<? for ($i=0; $i<count($list); $i++) { ?>
<tr>
    <td colspan=4 align=center>
        <table width=98% cellpadding=0 cellspacing=0 border=0>
        <tr>
            <td height=20> 
            <?
    echo $list[$i][icon_reply] . " ";
    #####################################################
    // join을 하지않고...
    // union all로 distinct 를 안하는 스타일로 게시판을 통합해서 쿼리를 하고
    // get_list함수를 이용하려면 wr_id,wr_hit,wr_subject 를 기준으로
    // 두 테이블중에 하나에서 쿼리하고 없으면 다른 테이블로 링크를 줘야만 될듯합니다.
    // 각각의 테이블이 테이블명을 가지고 있지 않기때문에 {$list[$i][href]} 에서 쿼리된
    // 결과를 링크할때 무조건 $bo_table 로 하기에.. 최선아니면 차선이죠..
    // 제목까지 잘랐으니 거의 올바른 경로가 될지..싶은데..
    // 2006.06.19 dalsoo.
    $this_id=""; $this_id_name=""; $sub_before_cut="";
    $sub_length=strlen($list[$i][subject]); 
    $sub_before_cut=trim(substr($list[$i][subject],0,$sub_length-4));                     
    $this_id=
     @mysql_result(@mysql_query("select wr_id,wr_hit, wr_subject  from $tmp_write_table01 where "
     ."(wr_subject like '$sub_before_cut%' and wr_id='{$list[$i][wr_id]}' and wr_hit='{$list[$i][wr_hit]}' "
     ."and wr_is_comment=0)"),0,0);
     //두번째 테이블에 제목+조회수+글번호가 일치하지 않으면 링크는 첫번째테이블이다.
     if($this_id !="")$list[$i][href]=str_replace("$bo_table02","$bo_table01",$list[$i][href]);
     //게시판:제목
     $this_ql="select bo_subject,bo_table from g4_board where bo_table ";
     if($this_id !="") $bo_table="$bo_table01"; else $bo_table="$bo_table02";
     $this_id_name=@mysql_result(@mysql_query("$this_ql= '$bo_table'"),0,0);
    echo "[<a href='{$list[$i][href]}'><font color='green'>$this_id_name</font></a>]  <a href='{$list[$i][href]}'>";
   ########################################################
            if ($list[$i]['is_notice'])
                echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list[$i]['subject']}</strong></font>";
            else
                echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list[$i]['subject']}</font>";
            echo "</a>";
            if ($list[$i]['comment_cnt'])
                echo " <a href=\"{$list[$i]['comment_href']}\"><span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list[$i]['comment_cnt']}</span></a>";
            // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
            // echo " " . $list[$i]['icon_new'];
            // echo " " . $list[$i]['icon_file'];
            // echo " " . $list[$i]['icon_link'];
            // echo " " . $list[$i]['icon_hot'];
            // echo " " . $list[$i]['icon_secret'];
            echo "<td width='75'><font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>[";
            echo "" . $list[$i]['datetime'];
            echo "]</font></td> ";
            ?></td></tr>
        </table></td>
</tr>

<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
</table>

댓글 전체

그렇게 적용했는데 에러가 나네요.  다시금 부탁드립니다.
//////////////////////////////////////////////////////
select * from g4_write_ union all select * from g4_write_공지사항/뉴스 order by wr_hit desc limit 0,10
1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '/뉴스 order by wr_hit desc limit 0,10' at line 1
error file : /index.php
lib/latest.lib.php 에 아래 소스를 추가했습니다.
다시금 부탁드립니다.
//////////////////////////////////////////////////////////////////
// Union table
function latest_union($skin_dir="", $bo_table01, $bo_table02, $rows=10, $subject_len=40, $options="")
{
    global $g4;
    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";
    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table01' OR bo_table = '$bo_table02'";
    $board = sql_fetch($sql);
    $tmp_write_table01 = $g4['write_prefix'] . $bo_table01; // 게시판 테이블 전체이름
    $tmp_write_table02 = $g4['write_prefix'] . $bo_table02; // 게시판 테이블 전체이름
     
    $sql = "select * from $tmp_write_table01 union all select * from $tmp_write_table02 order by wr_hit desc limit 0,10";
$result = sql_query($sql);

for ($i=0; $row = sql_fetch_array($result); $i++)
    $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
    ob_start();
    include "$latest_skin_path/latest.skin.php";   
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
자세히는 안봤구요, 대충보니 눈에 들어오는게 있어 말씀드립니다.
$sql = "select * from $tmp_write_table01 union all select * from $tmp_write_table02 order by wr_hit desc limit 0,10";
무조건 10개의 레코드를 뽑게 되어 있군요.
$sql = "select * from $tmp_write_table01 union all select * from $tmp_write_table02 order by wr_hit desc limit $rows";
이렇게 수정해보세요~
전체 6 |RSS
그누4 질문답변 내용 검색

회원로그인

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