테스트 사이트 - 개발 중인 베타 버전입니다

영카트 검색기능에서 3차분류명까지 검색이 가능할까요? 채택완료

메너 5년 전 조회 1,803

고수님들 아래 코드에서는 상품검색과 1차상품분류명까지 검색이 됩니다. 이 것을 2차,3차의 상품분류명까지 검색이 될 수 있도록 하려면 어디를 수정해야하는지 도움주시면 고맙겠습니다.

 

// 상품명에 검색어가 포한된것과 상품판매가능인것만 $sql_common = " from {$g5['g5_shop_item_table']} a, {$g5['g5_shop_category_table']} b ";

$where = array(); $where[] = " (a.ca_id = b.ca_id and a.it_use = 1 and b.ca_use = 1) ";

$search_all = true; // 상세검색 이라면 if (isset($_GET['qname']) || isset($_GET['qexplan']) || isset($_GET['qid']) || isset($_GET['qbasic']))     $search_all = false;

$q       = utf8_strcut(get_search_string(trim($_GET['q'])), 30, ""); $qname   = isset($_GET['qname']) ? trim($_GET['qname']) : ''; $qexplan = isset($_GET['qexplan']) ? trim($_GET['qexplan']) : ''; $qid     = isset($_GET['qid']) ? trim($_GET['qid']) : ''; $qbasic  = isset($_GET['qbasic']) ? trim($_GET['qbasic']) : ''; $qcaid   = isset($_GET['qcaid']) ? preg_replace('#[^a-z0-9]#i', '', trim($_GET['qcaid'])) : ''; $qfrom   = isset($_GET['qfrom']) ? preg_replace('/[^0-9]/', '', trim($_GET['qfrom'])) : ''; $qto     = isset($_GET['qto']) ? preg_replace('/[^0-9]/', '', trim($_GET['qto'])) : ''; if (isset($_GET['qsort']))  {     $qsort = trim($_GET['qsort']);     $qsort = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\s]/", "", $qsort); } else {     $qsort = ''; } if (isset($_GET['qorder']))  {     $qorder = preg_match("/^(asc|desc)$/i", $qorder) ? $qorder : ''; } else {     $qorder = ''; }

if(!($qname || $qexplan || $qid || $qbasic))     $search_all = true;

// 검색범위 checkbox 처리 $qname_check = false; $qexplan_check = false; $qid_check = false; $qbasic_check = false;

if($search_all) {     $qname_check = true;     $qexplan_check = true;     $qid_check = true;     $qbasic_check = true; } else {     if($qname)         $qname_check = true;     if($qexplan)         $qexplan_check = true;     if($qid)         $qid_check = true;     if($qbasic)         $qbasic_check = true; }

if ($q) {     $arr = explode(" ", $q);     $detail_where = array();     for ($i=0; $i

        $concat = array();         if ($search_all || $qname)             $concat[] = "a.it_name";         if ($search_all || $qexplan)             $concat[] = "a.it_explan2";         if ($search_all || $qid)             $concat[] = "b.ca_name";         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(" and ", $detail_where).")"; }

if ($qcaid)     $where[] = " a.ca_id like '$qcaid%' ";

if ($qfrom && $qto)     $where[] = " a.it_price between '$qfrom' and '$qto' ";

$sql_where = " where " . implode(" and ", $where);  

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

가능하지만 부하가 심할수 있으니 전체검색경우 전문개발자분과 상의후 진행해보세요!

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

메너
5년 전
감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인