카테고리 최신글 불러올때 리스트 출력방법 > 그누4 질문답변

그누4 질문답변

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

카테고리 최신글 불러올때 리스트 출력방법 정보

카테고리 최신글 불러올때 리스트 출력방법

본문

저번에도 유사한 질문 올렸었는데..
뭐 하나 풀리면 다른게 안되고, ㅜㅜ

이번엔 리스트 출력방법 질문입니다.

한 게시판에서 특정 카테고리의 제목(ca_name)을 뽑는것 까지는 성공했는데..
(가령 A게시판에 '가' '나' '다' '라' '마' '바'.........'하'의 카테고리가 있고 제가 필요한 최신글은 '다' '라' '마'인 경우)

그 해당 카테고리의 리스트를 불러오는데는 계속 실패를 합니다.
(그림 참조.. )

php를 전혀 모르고 그냥 필요한 부분만 짜집기 해놓은 상태라는 점 이해좀 해주세요 ;;

그럼 1)별도로 만들어놨떤 latest3.lib.php와 2)해당 latest.skin.php를 보여 드리겠습니다.

특히 latest3.lib.php에서 아래 부분이 의심이 갑니다만..

$sql = " select * from $tmp_write_table where ca_name = '$category' order by wr_num limit 0, $rows ";


제발.. 조언좀 부탁드립니다.

▣  latest3.lib.php

<?
if (!defined('_GNUBOARD_')) exit;

// 특정 카테고리 최신글 추출
function latest_cate($skin_dir="", $bo_table, $rows=10, $subject_len=40, $ca_name) // latest_cate
{
    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_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름

$sql = " select * from $tmp_write_table where ca_name = '$category' order by wr_num limit 0, $rows ";
   
//explain($sql);
    $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;
}
 ?>

▣  latest.skin.php

 <?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<style>
body,td,select,input,div,form,textarea,center,option,pre,blockquote {font-size:8pt;font-family:verdana;color:636363;line-height:160%;letter-spacing:-1px}

a:link    {color:636363;text-decoration:none}
a:visited  {color:636363;text-decoration:none}
a:active  {color:636363;text-decoration:none}
a:hover  {color:66cc99;text-decoration:underline}

.rini_ver3 {font-family:verdana;font-size:10px;letter-spacing:-1}
.rini_ver4 {font-family:verdana;font-size:9px;letter-spacing:-1}
</style>
<table border="0" width="100%">
<tr>
<td width="100%" style="border-bottom-width:2; border-bottom-style:solid;">&nbsp;<img src="<?=$latest_skin_path?>/img/z58.gif" border="0">&nbsp;
<strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><?=$ca_name?></a>&nbsp;&nbsp;</strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>&sca=<?=$ca_name?>'>More</a>&nbsp;</td>
    </tr>


<td width="100%"><? for ($i=0; $i<count($list); $i++) { ?></td>
    </tr>
    <tr>
<td colspan=2 style="border-top-width:1; border-bottom-width:1; border-top-style:none; border-bottom-style:dotted;">
<img src="<?=$latest_skin_path?>/img/icon.gif" border="0">
<font size="1" color="#00CC00">
<?
            echo $list[$i]['icon_reply'] . " ";
            echo "<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'];
            ?>
</font></td>
    </tr>
    <tr>
        <td width="100%">
  <? } ?>
          <? if (count($list) == 0) { ?>
  <tr><td colspan=2 align=center height=50><font color=#6A6A6A>게시물이 없읍니다.</font>
</td>
    </tr>
<? } ?>
</table>

댓글 전체

echo latest_cate("bolatest_a","full", 4,29, "Climate Change") ;

==> echo latest_cate("스킨","게시판명", 출력글수,제목길이제한,"불러올 카테고리") ;


이렇게 했습니다.. ^^;
앗. 넵.. ^^;; 
중간에  echo latest_cate("bolatest_a","full", 4,29,  "SD commission") ; 부분부터 입니다.
===================================================


<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

include_once("$g4[path]/head.sub.php");
include_once("$g4[path]/lib/outlogin.lib.php");
include_once("$g4[path]/lib/poll.lib.php");
include_once("$g4[path]/lib/visit.lib.php");
include_once("$g4[path]/lib/connect.lib.php");
include_once("$g4[path]/lib/popular.lib.php");
include_once("$g4[path]/lib/latest.lib.php");
include_once("$g4[path]/lib/latest3.lib.php");
include_once("./_common.php");


//print_r2(get_defined_constants());

// 사용자 화면 상단과 좌측을 담당하는 페이지입니다.
// 상단, 좌측 화면을 꾸미려면 이 파일을 수정합니다.

$table_width = 885;
?>
<script language="JavaScript">
<!--
function tick() {
var years, months, days, hours, minutes, seconds, ap;
var inYears, inMonts, inDays, intHours, intMinutes, intSeconds;
var today;
today = new Date();
inYears = today.getYear();
inMonts = (today.getMonth()+1);
inDays = today.getDate();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
years = inYears+"/";
if (inMonts < 10) { months = "0"+inMonts+"/"; } else { months = inMonts+"/"; }
if (inDays < 10) { days = "0"+inDays+" "; } else { days = inDays+" "; }
if (intHours == 0) { hours = "12:"; ap = "밤";
} else if (intHours < 12) { hours = intHours+":"; ap = "AM";
} else if (intHours == 12) { hours = "12:"; ap = "낮";
} else { intHours = intHours - 12; hours = intHours + ":"; ap = "PM"; }
if (intMinutes < 10) { minutes = "0"+intMinutes+":"; } else { minutes = intMinutes+":"; }
if (intSeconds < 10) { seconds = "0"+intSeconds+" "; } else { seconds = intSeconds+" "; }
timeString = years+months+days+hours+minutes+seconds+ap;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
//-->
</script>


<html>
<head>
<body oncontextmenu="return false"></body>

<!-- 상단 배경 시작 -->

<center>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<script language="JavaScript" src="http://www.sustain.kr/js/sustain.js"></script>
<img src="http://www.sustain.kr/newimage/test2.jpg" width="900" height="73" border="0" usemap="#ImageMap1"><map name="ImageMap1">
<area shape="rect" coords="7, 25, 199, 68" href="http://www.sustain.kr/index3.php" target="_parent">
<area shape="rect" coords="230, 46, 283, 65" href="http://www.sustain.kr/bbs/board.php?bo_table=full" target="_parent">
<area shape="rect" coords="578, 21, 732, 40" href="http://www.sustain.kr" target="_blank">
<area shape="rect" coords="738, 22, 790, 39" href="http://www.sustain.kr/shop.php" target="_blank">
<area shape="rect" coords="794, 22, 845, 39" href="http://www.sustain.kr/bbs/group.php?gr_id=menu_1" target="_blank">
<area shape="rect" coords="853, 23, 893, 39" href="http://www.sustain.kr/bbs/login.php?wr_id=168&url=board.php%3Fbo_table%3Dnotice_1%26wr_id%3D168" target="_blank">
</map>


</body>

<div style='margin-top:0px;'></div>

<body>
<table width="900" height="30" cellspacing="0" cellpadding="0">
  <TR>
<TD align="left" width="500">
<img src="http://www.sustain.kr/newimage/icn_notice_3.gif">
<?
    //echo latest("최신글 스킨", 게시판이름, 최신글보이는 수, 글자수);
      echo latest("gongji", full, 5, 70);
    ?>
</td>
<!--            <form name="fsearchbox" method="get" action="javascript:fsearchbox_submit(document.fsearchbox);">
            <input type="hidden" name="sfl" value="wr_subject">
            <input type="hidden" name="sop" value="and">
<td align="center"><font color="#333333"><div id="Clock" align="Center"></div></font></td> -->
<td align="center"><iframe id="weather" src="http://www.hankooki.com/iweather/data/wxbn.html" frameborder="0" marginwidth="0" marginheight="0" topmargin="0" style="width:100;height:25" scrolling="no"></iframe></td>

<!-- <td width="60" align="center"><img src="http://www.sustain.kr/skin/search/scbar/img/search_fr.gif" width="56" height="19" border=0 align=absmiddle></td>-->
    <td align="right"><input name="stx" maxlengt=20 onblur="this.style.background='#ffffff'"
                                style="BORDER-RIGHT: rgb(204,204,204) 1px solid; BORDER-TOP: rgb(204,204,204) 1px solid; BACKGROUND-IMAGE: url(http://dmbuser.com/search/images/sc_bg.gif); BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 190px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; HEIGHT: 19px"
                                onfocus="this.style.background='#ffffff'" size="20" maxlength="20"></td>
    <td width="51" align="right"> <input type="image" src="http://www.sustain.kr/skin/search/scbar/img/scin.gif" width="47" height="21" ></td>


    </tr>
  </form>

<script language="JavaScript">
function fsearchbox_submit(f)
{
    if (f.stx.value == '')
    {
        alert("검색어를 입력하세요.");
        f.stx.select();
        f.stx.focus();
        return;
    }

    /*
    // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
    var cnt = 0;
    for (var i=0; i<f.stx.value.length; i++)
    {
        if (f.stx.value.charAt(i) == ' ')
            cnt++;
    }

    if (cnt > 1)
    {
        alert("빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.");
        f.stx.select();
        f.stx.focus();
        return;
    }
    */

    f.action = "<?=$g4[bbs_path]?>/search.php";
    f.submit();
}
</script>


</tr>



</table>
</body>
<!-- 상단 배경 끝 -->

<div style='margin-top:1px;'></div>
<style type="text/css">
#middiv {
width:<?=$table_width?>px;
position:relative;
margin:0px auto;
    vertical-align:top;
    float:left;
}
#middiv #mleft  { width:200px; float:left; padding:0 0 0 43; }
#middiv #mright { width:683px; float:left; padding:0 0 0 15; }
</style>

<table width='<?=$table_width?>' cellpadding=0 cellspacing=0 border=0>
<tr>
 
<TD width=200 valign=top align="left" width="500">


<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<title>reft_main</title>
</head>
<body bgcolor="#ffffff">


<table bgcolor=#FfFfFf width=200>
 <tr>
<td width="200" height="250" align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="1" style="border-collapse:collapse; border:3px solid #D0D7CF;" width="200">
<tr>
<td width="200" height="23" align="center"><img src="http://www.sustain.kr/newimage/fa.gif" border=0 align=center></td></tr>

          </tr>
 <TR>
<TD>
<?
//echo latest_category("latest_ca","게시판명", 출력글수,제목길이제한) ;
  echo latest_cate("bolatest_a","full", 4,29, "Climate Change") ;
  ?>

</td></tr>

 <TR><TD>
<?
  echo latest_cate("bolatest_a","full", 4,29,  "SD commission") ;
?>
</td></tr>
 <TR><TD>
<?
  echo latest_cate("bolatest_a","full", 4,29,  "Guide Line") ;
?>
</td></tr>
 <TR><TD>
<?
  echo latest_cate("bolatest_a","full", 4,29,  "Local Agenda") ;
?>
</td></tr>

</table>


  <TR>
<td width="200" height="0" align="center" valign="top" cellpadding=0 cellspacing=0 border=0>&nbsp;&nbsp; </td>
        </tr>


<TR>
<TD>


</td>
 </tr>




<TR> <TD>
<?
  echo latest_cate("c_morning_DQ2", "full", 2, 29, "People") ;

 
?> </td>
</tr>
<TR>
<TD>

<?=latest_cate("c_morning_DQ2", "full", 2, 29, "Column");?>
</td>
 </tr>

 <tr>
          <td width="210" align="center" valign="top"<? echo latest("movie_play_1", "notice_5", 1, 25);?></td>
  </tr>

<tr>
<td width="205" height="88" align="center"><img src="http://www.sustain.kr/newimage/partners_2.jpg" width="205" height="88" border="0" usemap="#ImageMap2"><map name="ImageMap2">
<area shape="rect" coords="13, 48, 99, 75" href="http://www.koreatax.org/tax/index.php3" target="_blank">
<area shape="rect" coords="112, 14, 193, 40" href="http://www.koreacsr.com/" target="_blank">
<area shape="rect" coords="111, 48, 195, 76" href="http://www.ylc.or.kr/" target="_blank">
</map></td></tr>

</table>



</body>
</html>

<div style='margin-top:4px;'></div>
       
<?visit("elpis_counter1"); // 방문자수 ?>

        <div style='margin-top:4px;'></div>

    </td>
    <td width=10>&nbsp;</td>
    <!-- 중간 -->
    <td width=680 valign=top>
function latest_cate($skin_dir="", $bo_table, $rows=10, $subject_len=40, $ca_name) // latest_cate
{
    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_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름

$sql = " select * from $tmp_write_table where ca_name = '$category' order by wr_num limit 0, $rows ";


마지막 query 문에서 $category가 아니라 $ca_name이네요.
답변 감사합니다...

그런데 지적하신데로 했는데도 리스트에 아무것도 출력이 안됩니다.

마침 비슷한 스킨이 있어 $sql 부분만 바꿔서 테스트를 해봤는데도 역시 마찬가지입니다.

$sql = " select * from $tmp_write_table where wr_comment > -1 && ca_name = '$cat' order by wr_id desc limit 0, $rows ";

(위 스킨 주소는 http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=642&sca=%C0%CF%B9%DD )입니다.

혹시 다른 부분에 오류가  있는건 아닌지요.. 부탁드릴께요
echo $sql="select ....

이렇게 $sql 앞에 echo를 넣으면 실제 실행되는 query문을 볼 수 있습니다.

이걸 phpmysadmin  등에서 실행시켜서 원하는 결과가 나오는지 에러가 없는지 확인해 보세요.
엑스엠엘님의 관심어린 답변에도 불구하고 ㅜㅜ 사실 완전 초짜라 포토샵 빼고는 phpmysadmin를 잘 몰라요..

인터넷으로 phpmysadmin 검색해서 다운받고 설치해보려고 했는데 검색도 잘 안되고 설명도 잘 없어서 아직까지 에러 확인을 못하고 있어요..

그 와중에 비숫한 유형의 http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=657&page=41 파일을 다운받아 해봤는데도 역시 같은 증상..(리스트들을 안나옴.)

어디서 문제일지 뭔가 단서가 있나요?
전체 15 |RSS
그누4 질문답변 내용 검색

회원로그인

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