게시판 검색 기능 관련 질문드립니다!

게시판 검색 기능 관련 질문드립니다!

QA

게시판 검색 기능 관련 질문드립니다!

본문

검색 기능을 하는데 날짜와 약품명을 입력하면 해당되는 날짜와 약품명이 해당되는 리스트를 표출을 하게 하려고 하는데 입력을 하면 게시물이 없다고만 뜹니다 ㅠㅠㅠㅠㅠ


<form name="fsearch" method="get">
            <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
            <input type="hidden" name="sca" value="<?php echo $sca ?>">
            <input type="hidden" name="sop" value="and">
            <input type="hidden" name="sfl" value="wr_12" />
            <tr><input type="hidden" name="sfl" value="wr_1"<?php echo get_selected($sfl, 'wr_1'); ?>>구매일자</input>
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
                ~
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx2" value="<?php echo stripslashes($stx2) ?>" required id="stx2" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
                
            <input type="hidden" name="sfl" value="wr_subject"<?php echo get_selected($sfl, 'wr_subject'); ?>>약품명</input>
            <label for="stx3" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>        
                <input type="text" name="stx3" value="<?php echo stripslashes($stx3) ?>" required id="stx3" class="sch_input" size="25" maxlength="20" placeholder=" 검색어를 입력해주세요">               
            <button type="submit" value="검색" class="sch_btn"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>
            </tr>
            </form>

3537816078_1625029638.6055.png

이렇게 입력하고 검색하면 보이는 게시물이 검색이 되야 하는데

 

3537816078_1625029700.9001.png

이렇게 나오네요 ㅠㅠㅠㅠㅠ 어떻게 해결 해야 할까요??

이 질문에 댓글 쓰기 :

답변 4

1. common.lib.php에 있는 function get_sql_search() 함수를 이용할지 아니면

2. list.php에서 조건부로 $sql_search를 만들어 쓸지 정해야 합니다.

2번을 쓴다면
$is_search_bbs = false;
 
if ($sca || $stx || $stx === '0') {     //검색이면
    $is_search_bbs = true;      //검색구분변수 true 지정
    if($bo_table == "purchase_stock")
    $sql_search="{$sfl} between '{$stx}' and '{$stx2}'";
    else
    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);

이 부분을 수정하시면 됩니다.

 

 

            <form name="fsearch" method="get">
            <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
            <input type="hidden" name="sca" value="<?php echo $sca ?>">
            <input type="hidden" name="sop" value="and">
            <input type="hidden" name="sfl" value="wr_12" />
            <tr><input type="hidden" name="sfl" value="wr_1"<?php echo get_selected($sfl, 'wr_1'); ?>>구매일자</input>
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
                ~
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx2" value="<?php echo stripslashes($stx2) ?>" required id="stx2" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
            <input type="hidden" name="sfl" value="wr_subject"<?php echo get_selected($sfl, 'wr_subject'); ?>>약품명</input>
            <label for="stx3" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>        
                <input type="text" name="stx3" value="<?php echo stripslashes($stx3) ?>" required id="stx3" class="sch_input" size="25" maxlength="20" placeholder=" 검색어를 입력해주세요">               
            <button type="submit" value="검색" class="sch_btn"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>
            </tr>
            </form>

 

list.php에서

 

if ($sca || $stx || $stx === '0') { //검색이면

$is_search_bbs = true; //검색구분변수 true 지정

if($bo_table == "purchase_stock") {

 $sql_search=" wr_날짜들어간여분컬럼번호 between '{$stx1}' and '{$stx2}' and wr_약품명컬럼 like '%{$stx3}%' ";

}else $sql_search = get_sql_search($sca, $sfl, $stx, $sop);

해당 게시판 설정에서 전체검색 키셨을까요?

F12 개발자 툴을 통해 오류부분이 어디인지 스크립트처리는 어떻게 되었는지 알아야 답변이 가능 할 것같아요.

 

sfl 은 검색필드를 의미하고 stx는 검색어를 의미합니다.

예를 들어 게시판에서 제목과 내용을 검색할때

sfl = wr_subject||wr_content

stx = 검색어

와 같은 형태로 되어 있습니다.

 

위 내용대로라면 sfl 은 wr_subject 가 되고, stx 는 첫번째 날짜검색 필드이 값이 되겠네요.

이 부분을 이해하셔서 코드를 다시 짜셔야 하지만, 

코어를 건드리거나, 별도의 자바스크립트를 통해 sfl 을 새로 구성을 해주셔야 합니다.

하지만 날짜 검색 같은 경우는 코어를 수정하셔야 할 듯 합니다.

 

https://sir.kr/qa/419643

이 질문에서 보여 주셨던

소스를 다시 올려 보세요.

list.skin.php

  
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="//code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
    <script>
    $.datepicker.setDefaults({
        dateFormat: 'yy-mm',
        prevText: '이전 달',
        nextText: '다음 달',
        monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
        monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
        dayNames: ['일', '월', '화', '수', '목', '금', '토'],
        dayNamesShort: ['일', '월', '화', '수', '목', '금', '토'],
        dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
        showMonthAfterYear: true,
        yearSuffix: '년'
    });

        $(function() {
            $("#stx, #stx2, #e_Date").datepicker({
                dateFormat: 'yy-mm-dd'
            });
        });

    </script>
            <div style="width:<?php echo $width; ?>; text-align:left;">


       <!-- 날짜 검색 시작 { -->
            <form name="fsearch" method="get">
            <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
            <input type="hidden" name="sca" value="<?php echo $sca ?>">
            <input type="hidden" name="sop" value="and">
            <input type="hidden" name="sfl" value="wr_12" />
            <tr><input type="hidden" name="sfl" value="wr_1"<?php echo get_selected($sfl, 'wr_1'); ?>>구매일자</input>
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
                ~
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="text" name="stx2" value="<?php echo stripslashes($stx2) ?>" required id="stx2" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
            <input type="hidden" name="sfl" value="wr_subject"<?php echo get_selected($sfl, 'wr_subject'); ?>>약품명</input>
            <label for="stx3" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>        
                <input type="text" name="stx3" value="<?php echo stripslashes($stx3) ?>" required id="stx3" class="sch_input" size="25" maxlength="20" placeholder=" 검색어를 입력해주세요">               
            <button type="submit" value="검색" class="sch_btn"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>
            </tr>
            </form>
 </div>

common.lib.php

$str .= $op2;
            switch ($field[$k]) {
                 case "wr_12" :
 
                    $str .= " wr_1 between  '{$s[$i]}' and '$stx2' ";
 
                    break;
                case "mb_id" :
                case "wr_name" :
                    $str .= " $field[$k] = '$s[$i]' ";
                    break;

list.php

$is_search_bbs = false;
 
if ($sca || $stx || $stx === '0') {     //검색이면
    $is_search_bbs = true;      //검색구분변수 true 지정
    if($bo_table == "purchase_stock")
    $sql_search="{$sfl} between '{$stx}' and '{$stx2}'";
    else
    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);
 
    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)


소스코드는 이렇습니다! list.skin.php에서
 <input type="hidden" name="stx" value="<?php echo $stx ?>">
    <input type="hidden" name="stx2" value="<?php echo $stx2 = $_GET['stx2'] ? $_GET['stx2'] : ''; ?>">
이렇게 수정한 부분도 있습니다!

<form name="fsearch" method="get">
            <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
            <input type="hidden" name="sca" value="<?php echo $sca ?>">
            <input type="hidden" name="sop" value="and">
            <input type="hidden" name="sfl2" value="wr_1"<?php echo get_selected($sfl2, 'wr_1'); ?>>구매일자</input>
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="date" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
                ~
                <i class="fa fa-calendar" aria-hidden="true"></i> <input type="date" name="stx2" value="<?php echo stripslashes($stx2) ?>" required id="stx2" class="sch_input" size="25" maxlength="20" placeholder="날짜검색">
            <input type="hidden" name="sfl" value="wr_subject"<?php echo get_selected($sfl, 'wr_subject'); ?>>약품명</input>
            <label for="stx3" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>        
                <input type="text" name="stx3" value="<?php echo stripslashes($stx3) ?>" required id="stx3" class="sch_input" size="25" maxlength="20" placeholder=" 검색어를 입력해주세요">               
            <button type="submit" value="검색" class="sch_btn"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>
            </tr>
            </form>


이렇게 하시라는 말씀이 맞나요???

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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