검색결과에 그룹이름 출력 과 반복 안 되도록

검색결과에 그룹이름 출력 과 반복 안 되도록

QA

검색결과에 그룹이름 출력 과 반복 안 되도록

본문

어제 질문을 했었는데 그누보드 - 전체검색 스킨입니다. > 그누보드5 스킨 (sir.kr) 이 스킨을

기본으로 전체검색 결과에 그룹이름이 나오도록 수정하고 싶은데

그룹이름 출력이 되지 않습니다

그리고 검색결과 도출하는 반복문 내에 thead가 있다보니 분류 자체도 반복되어 출력되고 있어 

수정하고자 반복문 위로 입력하면 테이블이 깨져 수정할 수가 없습니다 .. 도와주시면

감사하겠습니다!

$group['gr_subject'] 는 당연히 해보았구요 


          <td class="group"> <?php
          $gr_id = $board['gr_id'];
          $gr = sql_query(" select gr_subject​ from g5_group where gr_id = '$gr_id' ");
          echo $gr['gr_subject'];?> </td>

구문 까지 사용했습니다 전체 소스가 필요할것 같아서 재 질문합니다!


<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');//썸네일 라이브러리
include_once('./_common.php');
 
?>
 
<!-- 전체검색 시작 { -->
<link rel="stylesheet" href="<?php echo $search_skin_url ?>/style.css">
 
<form name="fsearch" onsubmit="return fsearch_submit(this);" method="get">
  <input type="hidden" name="srows" value="<?php echo $srows ?>">
  <fieldset id="sch_res_detail">
    <legend>상세검색</legend>
    <?php echo $group_select ?>
    <script>document.getElementById("gr_id").value = "<?php echo $gr_id ?>";</script>
    <label for="sfl" class="sound_only">검색조건</label>
    <select name="sfl" id="sfl">
      <option value="wr_subject||wr_content"<?php echo get_selected($_GET['sfl'], "wr_subject||wr_content") ?>>제목+내용</option>
      <option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject") ?>>제목</option>
      <option value="wr_content"<?php echo get_selected($_GET['sfl'], "wr_content") ?>>내용</option>
      <option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id") ?>>회원아이디</option>
      <option value="wr_name"<?php echo get_selected($_GET['sfl'], "wr_name") ?>>이름</option>
    </select>
    <label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
    <input type="text" name="stx" value="<?php echo $text_stx ?>" id="stx" required class="frm_input required" maxlength="20">
    <input type="submit" class="btn_submit" value="검색">
    <script>
    function fsearch_submit(f)
    {
        if (f.stx.value.length < 2) {
            alert("검색어는 두글자 이상 입력하십시오.");
            f.stx.select();
            f.stx.focus();
            return false;
        }
 
        // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
        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 false;
        }
       
        f.action = "";
        return true;
    }
    </script>
    <input type="radio" value="or" <?php echo ($sop == "or") ? "checked" : ""; ?> id="sop_or" name="sop">
    <label for="sop_or">OR</label>
    <input type="radio" value="and" <?php echo ($sop == "and") ? "checked" : ""; ?> id="sop_and" name="sop">
    <label for="sop_and">AND</label>
  </fieldset>
</form>
<div id="sch_result">
  <?php
    if ($stx) {
        if ($board_count) {
    ?>
  <section id="sch_res_ov">
    <h2><?php echo $stx ?> 전체검색 결과</h2>
    <dl>
      <dt>게시판</dt>
      <dd><strong style="color:<?php echo $config['cf_search_color'] ?>"><?php echo $board_count ?>개</strong></dd>
      <dt>게시물</dt>
      <dd><strong style="color:<?php echo $config['cf_search_color'] ?>"><?php echo number_format($total_count) ?>개</strong></dd>
    </dl>
    <p><?php echo number_format($page) ?>/<?php echo number_format($total_page) ?> 페이지 열람 중</p>
  </section>
  <?php
        }
    }
    ?>
  <?php
    if ($stx) {
        if (!$board_count) {
     ?>
  <div id="sch_res_no">검색 결과가 없습니다.</div>
  <?php } }  ?>
  <hr>
  <?php if ($stx && $board_count) { ?>
  <section id="sch_res_list">
    <?php }  ?>
    <?php
    $k=0;
    for ($idx=$table_index, $k=0; $idx<count($search_table) && $k<$rows; $idx++) {
        $comment_def = "";
        $comment_href = "";
     ?>
    <h2><img src="<?php echo $search_skin_url ?>/img/icon_sch_board.gif" valign="absmiddle" /> <a href="./board.php?bo_table=<?php echo $search_table[$idx] ?>&<?php echo $search_query ?>"><?php echo $bo_subject[$idx] ?> <a href="./board.php?bo_table=<?php echo $search_table[$idx] ?>&<?php echo $search_query ?>"><img src="<?php echo $search_skin_url ?>/img/icon_sch_more.gif" alt="검색결과 더보기" /></a></h2>
        <?php
        for ($i=0; $i<count($list[$idx]) && $k<$rows; $i++, $k++) {
            if ($list[$idx][$i][wr_is_comment])
            {
                $comment_def = "<span class=\"cmt_def\">[댓글]</span>";
                $comment_href = "#c_".$list[$idx][$i][wr_id];
            }
      //썸네일 이미지 생성
      $thumb_info = get_list_thumbnail($search_table[$idx], $list[$idx][$i][wr_id],105,79);
      $sch_thumb = $thumb_info['src'];
     
      //파일명 조회
      $file_info['file'] = get_file($search_table[$idx], $list[$idx][$i][wr_id]);
      $sch_file=$file_info[file][0]['source'];
 
     ?>

 
<!-- 이후로 게시판 및 내용 표시 -->
    <div id="sch_res_cont">
      <table id="sum" summary="전체 게시판 검색결과" >
        <thead>
        <tr>
            <th scope="col">번호</th>
            <th scope="col">게시판명</th>
            <th scope="col">제목</th>
            <th scope="col">자료명</th>
            <th scope="col">작성자</th>
            <th scope="col">날짜</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td class="number"><?php echo $i+1 ?></td>
          <td class="group"> <?php echo $group['gr_subject'] ?> </td>
          <td class="board"> <?php echo $bo_subject[$idx] ?> </td>
          <td class="sch_res_title"><a href="<?php echo $list[$idx][$i][href] ?><?php echo $comment_href ?>" ><?php echo $comment_def ?><?php echo $list[$idx][$i][subject] ?></a> <a href="<?php echo $list[$idx][$i][href] ?><?php echo $comment_href ?>" target="_blank"> <img src="<?php echo $search_skin_url ?>/img/icon_sch_newwindow.gif" alt="새창"></a></td>
          <td class="file"> <?php if($sch_file){?>
             <img src="<?php echo $search_skin_url ?>/img/icon_sch_file.gif" alt="파일"> <?php echo $sch_file ?>
            <?php }  ?></td>
          <!--<td class="sch_res_cont_txt" valign="top"><?php echo mb_strimwidth($list[$idx][$i][content],'0','395','...','utf-8') ?></td>-->
          <td class="sch_res_cont_date" valign="bottom"><span class="sch_res_name"><?php echo $list[$idx][$i][name] ?> </span> </td>
          <td class="date"><?php echo date("Y.m.d h:m", strtotime($list[$idx][$i][wr_datetime])) ?></td>
        </tr>
        </tbody>
      </table>
    </div>
    <?php }  ?>
    <hr>
    <?php }  ?>
    <?php if ($stx && $board_count) {  ?>
  </section>
  <?php }  ?>
  <?php echo $write_pages ?> </div>
<!-- } 전체검색 끝 -->

 

이 질문에 댓글 쓰기 :

답변 2

테스트는 못해 봤지만 이런 식이면 될 겁니다.

<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');//썸네일 라이브러리
include_once('./_common.php');
 
?>
 
<!-- 전체검색 시작 { -->
<link rel="stylesheet" href="<?php echo $search_skin_url ?>/style.css">
 
<form name="fsearch" onsubmit="return fsearch_submit(this);" method="get">
  <input type="hidden" name="srows" value="<?php echo $srows ?>">
  <fieldset id="sch_res_detail">
    <legend>상세검색</legend>
    <?php echo $group_select ?>
    <script>document.getElementById("gr_id").value = "<?php echo $gr_id ?>";</script>
    <label for="sfl" class="sound_only">검색조건</label>
    <select name="sfl" id="sfl">
      <option value="wr_subject||wr_content"<?php echo get_selected($_GET['sfl'], "wr_subject||wr_content") ?>>제목+내용</option>
      <option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject") ?>>제목</option>
      <option value="wr_content"<?php echo get_selected($_GET['sfl'], "wr_content") ?>>내용</option>
      <option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id") ?>>회원아이디</option>
      <option value="wr_name"<?php echo get_selected($_GET['sfl'], "wr_name") ?>>이름</option>
    </select>
    <label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
    <input type="text" name="stx" value="<?php echo $text_stx ?>" id="stx" required class="frm_input required" maxlength="20">
    <input type="submit" class="btn_submit" value="검색">
    <script>
    function fsearch_submit(f)
    {
        if (f.stx.value.length < 2) {
            alert("검색어는 두글자 이상 입력하십시오.");
            f.stx.select();
            f.stx.focus();
            return false;
        }
 
        // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
        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 false;
        }
       
        f.action = "";
        return true;
    }
    </script>
    <input type="radio" value="or" <?php echo ($sop == "or") ? "checked" : ""; ?> id="sop_or" name="sop">
    <label for="sop_or">OR</label>
    <input type="radio" value="and" <?php echo ($sop == "and") ? "checked" : ""; ?> id="sop_and" name="sop">
    <label for="sop_and">AND</label>
  </fieldset>
</form>
<div id="sch_result">
  <?php
    if ($stx) {
        if ($board_count) {
    ?>
  <section id="sch_res_ov">
    <h2><?php echo $stx ?> 전체검색 결과</h2>
    <dl>
      <dt>게시판</dt>
      <dd><strong style="color:<?php echo $config['cf_search_color'] ?>"><?php echo $board_count ?>개</strong></dd>
      <dt>게시물</dt>
      <dd><strong style="color:<?php echo $config['cf_search_color'] ?>"><?php echo number_format($total_count) ?>개</strong></dd>
    </dl>
    <p><?php echo number_format($page) ?>/<?php echo number_format($total_page) ?> 페이지 열람 중</p>
  </section>
  <?php
        }
    }
    ?>
  <?php
    if ($stx) {
        if (!$board_count) {
     ?>
  <div id="sch_res_no">검색 결과가 없습니다.</div>
  <?php } }  ?>
  <hr>
  <?php if ($stx && $board_count) { ?>
  <section id="sch_res_list">
    <?php }  ?>
    <?php
    $k=0;
    for ($idx=$table_index, $k=0; $idx<count($search_table) && $k<$rows; $idx++) {
        $comment_def = "";
        $comment_href = "";
     ?>
    <h2><img src="<?php echo $search_skin_url ?>/img/icon_sch_board.gif" valign="absmiddle" /> <a href="./board.php?bo_table=<?php echo $search_table[$idx] ?>&<?php echo $search_query ?>"><?php echo $bo_subject[$idx] ?> <a href="./board.php?bo_table=<?php echo $search_table[$idx] ?>&<?php echo $search_query ?>"><img src="<?php echo $search_skin_url ?>/img/icon_sch_more.gif" alt="검색결과 더보기" /></a></h2>

        <div id="sch_res_cont">

<?php

    
          $gr_id = $list[$idx]; //$board['gr_id'];
          $gr = sql_query(" select gr_subject​ from g5_group where gr_id = '$gr_id' ");
          echo $g_subject= $gr['gr_subject'];
?>
      <table id="sum" summary="전체 게시판 검색결과" >
        <thead>
        <tr>
            <th scope="col">번호</th>
            <th scope="col">게시판명</th>
            <th scope="col">제목</th>
            <th scope="col">자료명</th>
            <th scope="col">작성자</th>
            <th scope="col">날짜</th>
        </tr>
        </thead>
        <tbody>


        <?php


        for ($i=0; $i<count($list[$idx]) && $k<$rows; $i++, $k++) {
            if ($list[$idx][$i][wr_is_comment])
            {
                $comment_def = "<span class=\"cmt_def\">[댓글]</span>";
                $comment_href = "#c_".$list[$idx][$i][wr_id];
            }
      //썸네일 이미지 생성
      $thumb_info = get_list_thumbnail($search_table[$idx], $list[$idx][$i][wr_id],105,79);
      $sch_thumb = $thumb_info['src'];
     
      //파일명 조회
      $file_info['file'] = get_file($search_table[$idx], $list[$idx][$i][wr_id]);
      $sch_file=$file_info[file][0]['source'];
 
     ?>

 
<!-- 이후로 게시판 및 내용 표시 -->

        <tr>
          <td class="number"><?php echo $i+1 ?></td>
          <td class="group"> <?php echo $group['gr_subject'] ?> </td>
          <td class="board"> <?php echo $bo_subject[$idx] ?> </td>
          <td class="sch_res_title"><a href="<?php echo $list[$idx][$i][href] ?><?php echo $comment_href ?>" ><?php echo $comment_def ?><?php echo $list[$idx][$i][subject] ?></a> <a href="<?php echo $list[$idx][$i][href] ?><?php echo $comment_href ?>" target="_blank"> <img src="<?php echo $search_skin_url ?>/img/icon_sch_newwindow.gif" alt="새창"></a></td>
          <td class="file"> <?php if($sch_file){?>
             <img src="<?php echo $search_skin_url ?>/img/icon_sch_file.gif" alt="파일"> <?php echo $sch_file ?>
            <?php }  ?></td>
          <!--<td class="sch_res_cont_txt" valign="top"><?php echo mb_strimwidth($list[$idx][$i][content],'0','395','...','utf-8') ?></td>-->
          <td class="sch_res_cont_date" valign="bottom"><span class="sch_res_name"><?php echo $list[$idx][$i][name] ?> </span> </td>
          <td class="date"><?php echo date("Y.m.d h:m", strtotime($list[$idx][$i][wr_datetime])) ?></td>
        </tr>

    <?php }  ?>

        </tbody>
      </table>
    </div>

    <hr>
    <?php }  ?>
    <?php if ($stx && $board_count) {  ?>
  </section>
  <?php }  ?>
  <?php echo $write_pages ?> </div>
<!-- } 전체검색 끝 -->
 

<?php
          $gr_id = $list[$idx]; //$board['gr_id'];
          $gr = sql_query(" select gr_subject​ from g5_group where gr_id = '$gr_id' ");
          echo $g_subject= $gr['gr_subject'];
?>
이 부분에서 출력이 없나요?

<?php
          $gr_id = $list[$idx]; //$board['gr_id'];
          $gr = sql_query(" select gr_subject​ from g5_group where gr_id = '$gr_id' ");
          echo $g_subject= $gr['gr_subject'];
?>
여기서
$list[ $idx]
대신에
$search_table[$idx]
를 사용해 보세요.

그룹이름 나오는 부분을 따로 불러 와서 한번만 실행해서 보여주면 될 것 같습니다.

 

bbs/search.php 에서 수정하면 됩니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 28
QA 내용 검색

회원로그인

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