검색할때 검색어랑 브랜드랑 같이 검색되게 하고 싶습니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
검색할때 검색어랑 브랜드랑 같이 검색되게 하고 싶습니다.

QA

검색할때 검색어랑 브랜드랑 같이 검색되게 하고 싶습니다.

본문

검색 카테고리를 직접 만들었는데 검색창에 검색어를 입력하고 난 후 카테고리에 있는 브랜드 명을 누르면 검색이 안됩니다. sql 문을 살펴봤는데 검색어만 검색했을 때는 concat() 안에 있는 변수들(a.it_name, a.it_explan2, a.it_id, a.it_basic) 로 select 문이 돌아가는데 그 이후 브랜드 명을 누르면  concat() 안에 있는 변수들이 사라져서 select 됩니다. 

 

select b.ca_id, b.ca_name, count(*) as cnt from g5_shop_item a, g5_shop_category b where (a.ca_id = b.ca_id and a.it_use = 1 and b.ca_use = 1) and (concat() like '%노트북%' ) and a.it_brand like '삼성%' group by b.ca_id order by b.ca_id
// 이 코드가 검색어와 브랜드를 같이 검색했을 때 나오는 sql 문입니다. 
// $q가 검색어입니다 
if ($q) {
    $arr = explode(" ", $q);
    $detail_where = array();
    for ($i=0; $i<count($arr); $i++) {
        $word = trim($arr[$i]);
        if (!$word) continue;
        $concat = array();
        if ($search_all || $qname)
            $concat[] = "a.it_name";
        if ($search_all || $qexplan)
            $concat[] = "a.it_explan2";
        if ($search_all || $qid)
            $concat[] = "a.it_id";
        if ($search_all || $qbasic)
            $concat[] = "a.it_basic";
        $concat_fields = "concat(".implode(",' ',",$concat).")";
        $detail_where[] = $concat_fields." like '%$word%' ";
        // 인기검색어
        insert_popular($concat, $word);
    }
    $where[] = "(".implode(" or ", $detail_where).")";

}
//브랜드 검색
if ($qbrand)
    $where[] = " a.it_brand like '$qbrand%' ";

 

skin에서는

 


<a href="#n" onclick = "set_it_brand('삼성')">삼성</a>
 
function set_it_brand(qbrand) //브랜드
{
    var f = document.frmdetailsearch;
    f.qbrand.value = qbrand;
    f.submit();
}

 

concat()안에 있는 변수들이 왜 사라질까요,.,????????????

이 질문에 댓글 쓰기 :

답변 4



if ($q) {
    $arr = explode(" ", $q);
    $detail_where = array();
    for ($i=0; $i<count($arr); $i++) {
        $word = trim($arr[$i]);
        if (!$word) continue;
        $concat = array();
        if ($search_all || $qname)
            $concat[] = "a.it_name";
        if ($search_all || $qexplan)
            $concat[] = "a.it_explan2";
        if ($search_all || $qid)
            $concat[] = "a.it_id";
        if ($search_all || $qbasic)
            $concat[] = "a.it_basic";
        $concat_fields = "concat(".implode(",' ',",$concat).")";
        $detail_where[] = $concat_fields." like '%$word%' ";
        // 인기검색어
        insert_popular($concat, $word);
    }
    //브랜드 검색
    if ($qbrand) $detail_where[] = " a.it_brand like '$qbrand%' ";
    $where[] = "(".implode(" or ", $detail_where).")";

}


 

위 코드처럼 해보세요. 단, 검색어가 있을때 브랜드도 같이 추출하는 조건입니다.

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

회원로그인

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