search.php 에서 카테고리 질문 드려요 채택완료

Copy
<?phpinclude_once('./_common.php'); $g5['title'] = $lang_common_330[$common_country_code];include_once(G5_MSHOP_PATH.'/_head.php'); // QUERY 문에 공통적으로 들어가는 내용// 상품명에 검색어가 포한된것과 상품판매가능인것만$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']))    $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']) : '';$qcaid   = isset($_GET['qcaid']) ? 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))     $search_all = true;   // 검색범위 checkbox 처리$qname_check = false;$qexplan_check = false;$qid_check = false; if($search_all) {    $qname_check = true;    $qexplan_check = true;    $qid_check = true;} else {    if($qname)        $qname_check = true;    if($qexplan)        $qexplan_check = true;    if($qid)        $qid_check = true;} 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";        $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 it_language='$common_country_code' and " . implode(" and ", $where); // 상품 출력순서가 있다면$qsort  = strtolower($qsort);$qorder = strtolower($qorder);$order_by = "";// 아래의 $qsort 필드만 정렬이 가능하게 하여 다른 필드로 하여금 유추해 볼수 없게함if (($qsort == "it_sum_qty" || $qsort == "it_price" || $qsort == "it_use_avg" || $qsort == "it_use_cnt" || $qsort == "it_update_time") &&    ($qorder == "asc" || $qorder == "desc")) {    $order_by = ' order by ' . $qsort . ' ' . $qorder . ' , it_order, it_id desc';} // 총몇개 = 한줄에 몇개 * 몇줄$items = $default['de_mobile_search_list_mod'] * $default['de_mobile_search_list_row'];// 페이지가 없으면 첫 페이지 (1 페이지)if ($page < 1) $page = 1;// 시작 레코드 구함$from_record = ($page - 1) * $items; // 검색된 내용이 몇행인지를 얻는다$sql = " select COUNT(*) as cnt $sql_common $sql_where ";$row = sql_fetch($sql);$total_count = $row['cnt'];$total_page  = ceil($total_count / $items); // 전체 페이지 계산?>  <!-- 검색 시작 { --><div id="ssch">     <!-- 상세검색 항목 시작 { -->    <div id="ssch_frm">        <form name="frmdetailsearch">        <input type="hidden" name="qsort" id="qsort" value="<?php echo $qsort ?>">        <input type="hidden" name="qorder" id="qorder" value="<?php echo $qorder ?>">        <input type="hidden" name="qcaid" id="qcaid" value="<?php echo $qcaid ?>">        <!--div>            <strong><?php echo $lang_common_331[$common_country_code] ?></strong>            <input type="checkbox" name="qname" id="ssch_qname" <?php echo $qname_check?'checked="checked"':'';?>> <label for="ssch_qname"><?php echo $lang_common_72[$common_country_code] ?></label>            <input type="checkbox" name="qexplan" id="ssch_qexplan" <?php echo $qexplan_check?'checked="checked"':'';?>> <label for="ssch_qexplan"><span class="sound_only"><?php echo $lang_common_63[$common_country_code] ?></span><?php echo $lang_search_5_m[$common_country_code] ?></label>            <!--input type="checkbox" name="qid" id="ssch_qid" <?php echo $qid_check?'checked="checked"':'';?>> <label for="ssch_qid"><span class="sound_only"><?php echo $lang_common_63[$common_country_code] ?></span><?php echo $lang_search_6_m[$common_country_code] ?></label><br>        </div>        <div>            <strong><?php echo $lang_common_332[$common_country_code] ?></strong>            <label for="ssch_qfrom" class="sound_only"><?php echo $lang_common_333[$common_country_code] ?></label>            <input type="text" name="qfrom" value="<?php echo $qfrom; ?>" id="ssch_qfrom" class="frm_input"> ~            <label for="ssch_qto" class="sound_only"><?php echo $lang_common_334[$common_country_code] ?></label>            <input type="text" name="qto" value="<?php echo $qto; ?>" id="ssch_qto" class="frm_input"><?php echo $lang_common_335[$common_country_code] ?><br>        </div-->        <div>            <label for="ssch_q" class="ssch_lbl"><?php echo $lang_common_148[$common_country_code] ?></label>            <input type="text" name="q" value="<?php echo $q; ?>" id="ssch_q" class="frm_input" maxlength="30">            <input type="submit" value="검색" class="btn_submit" style="height:45px;">        </div>        <!--p>            <?php echo $lang_common_336[$common_country_code] ?><br>            <?php echo $lang_common_337[$common_country_code] ?>        </p-->        </form>         <ul id="ssch_sort">            <li><a href="#" class="btn01" onclick="set_sort('it_sum_qty', 'desc'); return false;"><?php echo $lang_common_338[$common_country_code] ?></a></li>            <li><a href="#" class="btn01" onclick="set_sort('it_price', 'asc'); return false;"><?php echo $lang_common_339[$common_country_code] ?></a></li>            <li><a href="#" class="btn01" onclick="set_sort('it_price', 'desc'); return false;"><?php echo $lang_common_340[$common_country_code] ?></a></li>            <li><a href="#" class="btn01" onclick="set_sort('it_use_avg', 'desc'); return false;"><?php echo $lang_common_341[$common_country_code] ?></a></li>            <li><a href="#" class="btn01" onclick="set_sort('it_use_cnt', 'desc'); return false;"><?php echo $lang_common_342[$common_country_code] ?></a></li>            <li><a href="#" class="btn01" onclick="set_sort('it_update_time', 'desc'); return false;"><?php echo $lang_common_343[$common_country_code] ?></a></li>        </ul>         <div id="ssch_ov">            <?php echo $lang_common_344[$common_country_code] ?><b><?php echo $total_count; ?></b><?php echo $lang_common_86[$common_country_code] ?>        </div>    </div>    <!-- } 상세검색 항목 끝 -->     <!-- 검색된 분류 시작 { -->    <div id="ssch_cate">        <ul>        <?php        $sql = " select b.ca_id, b.ca_name, count(*) as cnt $sql_common $sql_where group by b.ca_id order by b.ca_id ";        $result = sql_query($sql);        $total_cnt = 0;        for ($i=0; $row=sql_fetch_array($result); $i++) {            echo "<li><a href=\"#\" onclick=\"set_ca_id('{$row['ca_id']}'); return false;\">{$row['ca_name']} (".$row['cnt'].")</a></li>\n";            $total_cnt += $row['cnt'];        }        echo '<li><a href="#" onclick="set_ca_id(\'\'); return false;">'.$lang_common_345[$common_country_code].' <span>('.$total_cnt.')</span></a></li>'.PHP_EOL;        ?>        </ul>    </div>    <!-- } 검색된 분류 끝 -->     <!-- 검색결과 시작 { -->    <div>        <?php        // 리스트 유형별로 출력        define('G5_SHOP_CSS_URL', G5_MSHOP_SKIN_URL);        $list_file = G5_MSHOP_SKIN_PATH.'/'.$default['de_mobile_search_list_skin'];          if (file_exists($list_file)) {              $list = new item_list($list_file, $default['de_mobile_search_list_mod'], $default['de_mobile_search_list_row'], $default['de_mobile_search_img_width'], $default['de_mobile_search_img_height']); 			$list->set_query(" select * $sql_common $sql_where {$order_by} ");			$list->set_mobile(true);            $list->set_type(1);			$list->set_language($common_country_code);            $list->set_view('it_id', false);            $list->set_view('it_name', true);            $list->set_view('it_cust_price', true);            $list->set_view('it_price', true);            $list->set_view('it_icon', true);            $list->set_view('sns', true);            echo $list->run(); 			/*			$list = new item_list($list_file, $default['de_mobile_search_list_mod'], $default['de_mobile_search_list_row'], $default['de_mobile_search_img_width'], $default['de_mobile_search_img_height']);            //$list->set_query(" select * $sql_common $sql_where {$order_by} limit $from_record, $items ");            $list->set_is_page(true);            $list->set_mobile(true);			//$list->set_language($common_country_code);            $list->set_view('it_img', true);            $list->set_view('it_id', false);            $list->set_view('it_name', true);            $list->set_view('it_basic', true);            $list->set_view('it_cust_price', false);            $list->set_view('it_price', true);            $list->set_view('it_icon', true);            $list->set_view('sns', true);            echo $list->run();			*/        }        else        {            $i = 0;            $error = '<p class="sct_nofile">'.$list_file.$lang_common_27[$common_country_code].'</p>';        }         if ($i==0)        {            echo '<div>'.$error.'</div>';        }         $query_string = 'qname='.$qname.'&amp;qexplan='.$qexplan.'&amp;qid='.$qid;        if($qfrom && $qto) $query_string .= '&amp;qfrom='.$qfrom.'&amp;qto='.$qto;        $query_string .= '&amp;qcaid='.$qcaid.'&amp;q='.urlencode($q);        $query_string .='&amp;qsort='.$qsort.'&amp;qorder='.$qorder;        echo get_paging($config['cf_mobile_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'].'?'.$query_string.'&amp;page=');        ?>    </div>    <!-- } 검색결과 끝 --> </div><!-- } 검색 끝 --> <script>function set_sort(qsort, qorder){    var f = document.frmdetailsearch;    f.qsort.value = qsort;    f.qorder.value = qorder;    f.submit();} function set_ca_id(qcaid){    var f = document.frmdetailsearch;    f.qcaid.value = qcaid;    f.submit();}</script> <?phpinclude_once(G5_MSHOP_PATH.'/_tail.php');?>

안녕하세요 search.php 인데요, 제가 궁금한게 있는데요,

상품의 카테고리 부분에서요

Copy
<!-- 검색된 분류 시작 { -->    <div id="ssch_cate">        <ul>        <?php        $sql = " select b.ca_id, b.ca_name, count(*) as cnt $sql_common $sql_where group by b.ca_id order by b.ca_id ";        $result = sql_query($sql);        $total_cnt = 0;        for ($i=0; $row=sql_fetch_array($result); $i++) {            echo "<li><a href=\"#\" onclick=\"set_ca_id('{$row['ca_id']}'); return false;\">{$row['ca_name']} (".$row['cnt'].")</a></li>\n";            $total_cnt += $row['cnt'];        }        echo '<li><a href="#" onclick="set_ca_id(\'\'); return false;">'.$lang_common_345[$common_country_code].' <span>('.$total_cnt.')</span></a></li>'.PHP_EOL;        ?>        </ul>    </div>    <!-- } 검색된 분류 끝 -->

이 부분에서요 특정 카테고리를 클릭하면 for문에서 출력되는 카테고리가 클릭한 카테고리 빼고 다 사라지더라구요. 전체클릭하면 다시 모든 카테고리가 나오는데, 특정 카테고리를 선택하면 그 카테고리빼고 나머지 카테고리가 빠집니다.

해당 부분은 db에서 손을 봐야 할거 같은데, 이부분을 어떻게 손을 대야할지 도저히 모르겠네요.

그누보드 고수님들 어찌할지 좀 알려주세요

답변 1개

채택된 답변
+20 포인트

특정 카테고리를 선택하면,

선택한 카테고리만 나오는게 맞지 않아요 ?

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

답변에 대한 댓글 1개

카테고리 상품을 말하는게 아니라 카테고리 목록을 말하는겁니다ㅜㅜ

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

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

로그인
🐛 버그신고