전체 검색 페이지 문의드립니다~!!!! ㅠㅠ

전체 검색 페이지 문의드립니다~!!!! ㅠㅠ

QA

전체 검색 페이지 문의드립니다~!!!! ㅠㅠ

본문

통합 검색 페이지에 검색 시 
게시판 두개에서 검색되도록 작업하였는데 


예)

"하이" 검색 시 
A 게시판에서 "하이" 가 들어간 게시물이 


        1  2
        3  4

        5  6
< 페이징 버튼 >


나오고 그 밑에 
B 게시판에서 "하이" 가 들어간 게시물이 


    1  2  3  4

    5  6  7  8
< 페이징 버튼 >


이렇게 나오게 했고

확인하다 보니 문제가 ...

제가 2개 게시판 게시물을 총 10개 미만으로 올려놔서 잘 나오는 줄 알았는데

10개가 넘어가니 위에처럼 A 게시판 6개, B 게시판 8개가 나오는게 아니라

A 게시판 6개, B 게시판 4개 이렇게 나오더라구요 ....
그래서 A 게시판 게시물 수가 10개면 A 게시판만 10개 나오고

B 게시판은 안나오는 문제가 발생해버렸어요 ..... ㅠㅠ 

위에 보여드린 것처럼 A, B 게시물이 총 10개 이상이라도 
무조건 A 게시판은 6개씩, B 게시판은 8개씩 나오도록 해야하는데 

아무리 검색해서 찾아보고 해봐도 안되더라구요 ... ㅠㅠ 
할수 있는건데 제가 못하는거겠죠 ... ?

 

그리고 페이징 버튼도 A, B 따로 나오도록 했는데 
2 페이지 버튼을 누르면 A, B 게시판이 같이 2페이지로 이동이 되서 
A 게시물에서 2 페이지를 누르면 A 게시물만 2페이지로 가고

B 게시물은 그대로 1페이지로 나오도록 하고 싶어서요 .. 

대체 어떻게 해야 할까요 ..? ㅠㅠ 
제발 도와주세요 ㅠㅠ 

혹시 몰라 search.skin.php 작업된 내용 같이 올려요

고수님들 제발 도와주세요 ㅠㅠㅠㅠㅠㅠㅠㅠ
힌트라도 부탁드려요 힌트주시면 제가 열심히 해볼께요 !! ㅠㅠㅠㅠ



<!-- 전체검색 시작 { -->
<form name="fsearch" onsubmit="return fsearch_submit(this);" method="get">
    <input type="hidden" name="srows" value="<?php echo $srows ?>">
    <input type="hidden" name="gr_id" value="community">
    <input type="hidden" name="sfl" value="wr_subject||wr_content||ca_name||wr_name">
    <fieldset id="sch_res_detail">
        <legend>상세검색</legend>
        <label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
        <span class="sch_wr">
            <input type="text" name="stx" placeholder="검색어를 입력해주세요" value="<?php echo $text_stx ?>" id="stx" required class="frm_input" size="40">
            <button type="submit" class="btn_submit"></button>
        </span>
                            
<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>
</fieldset>
 
 
<?php
    $k=0;
    for ($idx=$table_index, $k=0; $idx<count($search_table) && $k<$rows; $idx++) {
        $cnt = $search_table[$idx];
    ?>
    <?php if($search_table[$idx] == 'before_after') { ?>
    <div class="search_board_result">
        <p class="search_board_title">
            <a href="<?php echo get_pretty_url($search_table[$idx], '', $search_query); ?>">
                <span class="fz_20 ls_p5 lh_16 kopubworlddotum normal" style="color:#787878;"><?php echo $bo_subject[$idx] ?></span> <span class="fz_20 ls_p5 lh_16 kopubworlddotum semibold" style="color:#000;"><?php echo $table_cnt[$cnt]; ?>건</span>
            </a>
        </p>
        <ul class="">
        <?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"><i class="fa fa-commenting-o" aria-hidden="true"></i><span class="sound_only">댓글</span></span> ';
                $comment_href = '#c_'.$list[$idx][$i]['wr_id'];
            } else {
                $comment_def = '';
                $comment_href = '';
            }
            // 이미지파일 호출
            $file = get_file($search_table[$idx], $list[$idx][$i]['wr_id']);
        ?>
                        
            <li>
                <div class="sch_tit sch_tit_bna ta_c">
                    <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>" class="sch_res_title sch_res_title_bna">
                        <span class="s71_search_bna_text fz_19 lh_16 kopubworlddotum semibold">[<?php echo $list[$idx][$i]['ca_name'] ?>]</span>
                        <span class="s71_search_bna_text fz_19 lh_16 kopubworlddotum normal"><?php echo $list[$idx][$i]['subject'] ?></span>
                    </a>
                </div>
                <div class="s71_search_img">
                    <?php
                        $thumb_width = 319;
                        $thumb_height = 189;
                        if(preg_match("/\.({$config['cf_image_extension']})$/i", $file[0]['file'])) {
                            $file_src1 = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
                        }else {
                            $file_src1 = '<img src="'.G5_THEME_URL.'/img/noimage.png"> width="'.$thumb_width.'"';
                        }
                        if(preg_match("/\.({$config['cf_image_extension']})$/i", $file[1]['file'])) {
                            $file_src2 = '<img src="'.$file[1]['path'].'/'.$file[1]['file'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
                        }else {
                            $file_src2 = '<img src="'.G5_THEME_URL.'/img/noimage.png"> width="'.$thumb_width.'"';
                        }
                    ?>
                    <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>">
                        <div class="s71_search_img_bna s71_search_img_b">
                            <?php echo $file_src1; ?>
                            <p class="s71_search_bna_txt fz_16 lh_16 kopubworlddotum normal">
                               <span>BEFORE</span><span><?php echo $list[$idx][$i]['wr_1'] ?></span> 
                            </p>
                        </div>
                        <div class="s71_search_img_bna s71_search_img_a">
                            <?php echo $file_src2; ?>
                            <p class="s71_search_bna_txt fz_16 lh_16 kopubworlddotum normal">
                                <span>AFTER</span><span><?php echo $list[$idx][$i]['wr_2'] ?></span> 
                            </p>
                        </div>
                    </a>
                </div>
            </li>
        <?php } ?>
        </ul>
                    
        <?php echo $write_pages ?>
                    
    </div>
    <?php } ?>
                
                
    <?php if($search_table[$idx] == 'c_article') { ?>
    <div class="search_board_result search_board_result_article">
        <p class="search_board_title">
            <a href="<?php echo get_pretty_url($search_table[$idx], '', $search_query); ?>">
                <span class="fz_20 ls_p5 lh_16 kopubworlddotum normal" style="color:#787878;"><?php echo $bo_subject[$idx] ?></span> <span class="fz_20 ls_p5 lh_16 kopubworlddotum semibold" style="color:#000;"><?php echo $table_cnt[$cnt]; ?>건</span>
            </a>
        </p>
        <ul class="article_ul">
        <?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"><i class="fa fa-commenting-o" aria-hidden="true"></i><span class="sound_only">댓글</span></span> ';
                $comment_href = '#c_'.$list[$idx][$i]['wr_id'];
            } else {
                $comment_def = '';
                $comment_href = '';
            }
            // 이미지파일 호출
            $file = get_file($search_table[$idx], $list[$idx][$i]['wr_id']);
        ?>
            <li class="article_li">
                <div class="s71_search_img">
                    <?php
                    $thumb_width = 311;
                    $thumb_height = 311;
                    if(preg_match("/\.({$config['cf_image_extension']})$/i", $file[0]['file'])) {
                        $file_src1 = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
                    }else {
                        $file_src1 = '<img src="'.G5_THEME_URL.'/img/noimage.png"> width="'.$thumb_width.'"';
                    }
                    ?>
                    <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>">
                        <div class="s71_search_img_article">
                            <?php echo $file_src1; ?>
                        </div>
                    </a>
                </div>
                <div class="sch_tit sch_tit_arti">
                    <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>" class="sch_res_title sch_res_title_article">
                        <p class="s71_search_arti_text txt01 fz_16 ls_p2 lh_16 kopubworlddotum semibold"><?php echo $list[$idx][$i]['ca_name'] ?></p>
                        <p class="s71_search_arti_text txt02 fz_20 lh_16 kopubworlddotum normal"><?php echo $list[$idx][$i]['subject'] ?></p>
                    </a>
                </div>
            </li>
        <?php } ?>
        </ul>
        <?php echo $write_pages ?>
    </div>
    <?php } ?>
<?php } //end for ?>

이 질문에 댓글 쓰기 :

답변 3

다음과 같이 해 볼 수 있지 않을까 생각합니다.

참고 하셔서 원하시는 형식으로 구현해 보세요


$k_a = 0;
$k_b = 0;
for ($idx=$table_index; $idx<count($search_table) && ($k_a + $k_b)<$rows; $idx++) {
    $cnt = $search_table[$idx];
    // ... (기존 코드 유지)
    if ($search_table[$idx] == 'before_after') {
        // ... (기존 코드 유지)
        for ($i=0; $i<count($list[$idx]) && ($k_a + $k_b)<$rows; $i++) {
            // ... (기존 코드 유지)
            if ($list[$idx][$i]['board'] == 'A') {
                // A 게시판의 경우
                // ... (기존 코드 유지)
                $k_a++;
            } elseif ($list[$idx][$i]['board'] == 'B') {
                // B 게시판의 경우
                // ... (기존 코드 유지)
                $k_b++;
            }
        }
        // ... (기존 코드 유지)
    }
    // ... (기존 코드 유지)
}

 

페이징 부분 수정


// A 게시판 페이징 버튼
echo $write_pages_a;
// B 게시판 페이징 버튼
echo $write_pages_b;

 

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

회원로그인

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