영카트 검색기능에서 3차분류명까지 검색이 가능할까요? 채택완료
고수님들 아래 코드에서는 상품검색과 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개
답변을 작성하려면 로그인이 필요합니다.
로그인