From f46429fcb08bf9fe545d9540f7788af35de7ff04 Mon Sep 17 00:00:00 2001 From: whitedot Date: Thu, 2 May 2013 11:23:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=87=BC=ED=95=91=EB=AA=B0:=20#115=20=EC=83=81?= =?UTF-8?q?=ED=92=88=EA=B2=80=EC=83=89=20=EC=9E=91=EC=97=85=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shop/search.php | 160 +++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 85 deletions(-) diff --git a/shop/search.php b/shop/search.php index 24b9ef296..441b0a302 100644 --- a/shop/search.php +++ b/shop/search.php @@ -5,98 +5,88 @@ include_once('./_common.php'); // 0 으로 설정하면 오류남 : 기본 2 $image_rate = 2; -$g4['title'] = "상품 검색"; +$g4['title'] = "상품 검색 결과"; include_once('./_head.php'); + +// QUERY 문에 공통적으로 들어가는 내용 +// 상품명에 검색어가 포한된것과 상품판매가능인것만 +$sql_common = " from {$g4['shop_item_table']} a, + {$g4['shop_category_table']} b + where a.ca_id=b.ca_id + and a.it_use = 1 + and b.ca_use = 1 + /* 중복검색에 대한 오류로 인해 막음 : where (a.ca_id=b.ca_id or a.ca_id2=b.ca_id or a.ca_id3=b.ca_id) */ "; +if ($search_str) { + $sql_common .= " and ( a.it_id like '$search_str%' or + a.it_name like '%$search_str%' or + a.it_basic like '%$search_str%' or + a.it_explan like '%$search_str%' ) "; +} +/* +// 공백을 구분하여 검색을 할때는 이 코드를 사용하십시오. or 조건 +if ($search_str) { + $s_str = explode(" ", $search_str); + $or = " "; + $sql_common .= " and ( "; + for ($i=0; $i 0) { + if (trim($search_str)) { + // 인기검색어 + $sql = " insert into {$g4['popular_table']} + set pp_word = '$search_str', + pp_date = '".G4_TIME_YMD."', + pp_ip = '{$_SERVER['REMOTE_ADDR']}' "; + sql_query($sql, FALSE); + } + + unset($save); // 임시 저장 배열 + $sql = " select a.ca_id, + a.it_id + $sql_common + order by a.ca_id, a.it_id desc "; + $result = sql_query($sql); + for ($i=0; $row=mysql_fetch_array($result); $i++) { + if ($save['ca_id'] != $row['ca_id']) { + if ($save['ca_id']) { + write_search_save($save); + unset($save); + } + $save['ca_id'] = $row['ca_id']; + $save['cnt'] = 0; + } + $save['it_id'][$save['cnt']] = $row['it_id']; + $save[cnt]++; + } +} ?> -

- - - - - -
-    찾으시는 검색어는 "" 입니다. -

- {$total_count}건의 상품이 검색 되었습니다.

"; - - // 임시배열에 저장해 놓고 분류별로 출력한다. - // write_serarch_save() 함수가 임시배열에 있는 내용을 출력함 - if ($total_count > 0) { - if (trim($search_str)) { - // 인기검색어 - $sql = " insert into {$g4['popular_table']} - set pp_word = '$search_str', - pp_date = '".G4_TIME_YMD."', - pp_ip = '{$_SERVER['REMOTE_ADDR']}' "; - sql_query($sql, FALSE); - } - - unset($save); // 임시 저장 배열 - $sql = " select a.ca_id, - a.it_id - $sql_common - order by a.ca_id, a.it_id desc "; - $result = sql_query($sql); - for ($i=0; $row=mysql_fetch_array($result); $i++) { - if ($save['ca_id'] != $row['ca_id']) { - if ($save['ca_id']) { - write_search_save($save); - unset($save); - } - $save['ca_id'] = $row['ca_id']; - $save['cnt'] = 0; - } - $save['it_id'][$save['cnt']] = $row['it_id']; - $save[cnt]++; - } - mysql_free_result($result); - write_search_save($save); - } - ?> -
+

검색어 , 검색 결과