202 lines
7.2 KiB
PHP
202 lines
7.2 KiB
PHP
<?php
|
|
include_once('./_common.php');
|
|
|
|
if (G5_IS_MOBILE) {
|
|
include_once(G5_MSHOP_PATH.'/search.php');
|
|
return;
|
|
}
|
|
|
|
$g5['title'] = "상품 검색 결과";
|
|
include_once('./_head.php');
|
|
|
|
$q = utf8_strcut(escape_trim($_GET['q']), 30, "");
|
|
$qname = escape_trim($_GET['qname']);
|
|
$qexplan = escape_trim($_GET['qexplan']);
|
|
$qid = escape_trim($_GET['qid']);
|
|
$qcaid = escape_trim($_GET['qcaid']);
|
|
$qfrom = escape_trim($_GET['qfrom']);
|
|
$qto = escape_trim($_GET['qto']);
|
|
$qsort = escape_trim($_GET['qsort']);
|
|
|
|
// 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($qname) || isset($qexplan) || isset($qid))
|
|
$search_all = false;
|
|
|
|
if ($q) {
|
|
$arr = explode(" ", $q);
|
|
$detail_where = array();
|
|
for ($i=0; $i<count($arr); $i++) {
|
|
$word = trim($arr[$i]);
|
|
if (!$word) continue;
|
|
|
|
/*
|
|
$or = array();
|
|
if ($search_all || $qname)
|
|
$or[] = " a.it_name like '%$word%' ";
|
|
if ($search_all || $qexplan)
|
|
$or[] = " a.it_explan2 like '%$word%' "; // tag 를 제거한 상품설명을 검색한다.
|
|
if ($search_all || $qid)
|
|
$or[] = " a.it_id like '%$word%' ";
|
|
|
|
$detail_where[] = "(" . implode(" or ", $or) . ")";
|
|
*/
|
|
$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%' ";
|
|
|
|
// 인기검색어
|
|
$sql = " insert into {$g5['popular_table']} set pp_word = '$word', pp_date = '".G5_TIME_YMD."', pp_ip = '{$_SERVER['REMOTE_ADDR']}' ";
|
|
sql_query($sql, FALSE);
|
|
}
|
|
|
|
$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);
|
|
|
|
// 상품 출력순서가 있다면
|
|
$order_by = "";
|
|
if ($qsort != "") {
|
|
$order_by = ' order by ' . $qsort . ' ' . $qorder . ' , it_order, it_id desc';
|
|
}
|
|
|
|
// 총몇개 = 한줄에 몇개 * 몇줄
|
|
$items = $default['de_search_list_mod'] * $default['de_search_list_row'];
|
|
// 페이지가 없으면 첫 페이지 (1 페이지)
|
|
if ($page == "") $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 ?>">
|
|
<div>
|
|
<strong>검색범위</strong>
|
|
<label><input type="checkbox" name="qname" class="frm_input" <?php echo isset($qname)?'checked="checked"':'';?>> 상품명</label>
|
|
<label><input type="checkbox" name="qexplan" class="frm_input" <?php echo isset($qexplan)?'checked="checked"':'';?>> 상품설명</label>
|
|
<label><input type="checkbox" name="qid" class="frm_input" <?php echo isset($qid)?'checked="checked"':'';?>> 상품코드</label><br>
|
|
</div>
|
|
<div>
|
|
<strong>상품가격</strong>
|
|
<input type="text" name="qfrom" value="<?php echo $qfrom; ?>" class="frm_input" size="10">원 부터
|
|
<input type="text" name="qto" value="<?php echo $qto; ?>" class="frm_input" size="10">원 까지<br>
|
|
</div>
|
|
<div>
|
|
<strong>검색어</strong>
|
|
<input type="text" name="q" value="<?php echo $q; ?>" class="frm_input" size="40" maxlength="30">
|
|
<input type="submit" value="검색" class="btn_submit">
|
|
</div>
|
|
<p>
|
|
상세검색을 선택하지 않거나, 상품가격을 입력하지 않으면 전체에서 검색합니다.<br>
|
|
검색어는 최대 30글자까지, 여러개의 검색어를 공백으로 구분하여 입력 할수 있습니다.
|
|
</p>
|
|
</form>
|
|
|
|
<script>
|
|
function set_sort(qsort, qorder)
|
|
{
|
|
var f = document.frmdetailsearch;
|
|
f.qsort.value = qsort;
|
|
f.qorder.value = qorder;
|
|
f.submit();
|
|
}
|
|
</script>
|
|
|
|
<ul id="ssch_sort">
|
|
<li><a href="#" class="btn01" onclick="set_sort('it_sum_qty', 'desc'); return false;">판매량 많은순</a></li>
|
|
<li><a href="#" class="btn01">선호도 높은순</a></li>
|
|
<li><a href="#" class="btn01" onclick="set_sort('it_use_cnt', 'desc'); return false;">사용후기 많은순</a></li>
|
|
<li><a href="#" class="btn01">최근 등록순</a></li>
|
|
</ul>
|
|
|
|
<div id="ssch_ov">
|
|
검색 결과 <b><?php echo $total_count; ?></b>건
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<?php
|
|
// 리스트 유형별로 출력
|
|
$list_file = G5_SHOP_SKIN_PATH.'/'.$default['de_search_list_skin'];
|
|
if (file_exists($list_file)) {
|
|
|
|
$list = new item_list($default['de_search_list_skin'], $default['de_search_list_mod'], $default['de_search_list_row'], $default['de_search_img_width'], $default['de_search_img_height']);
|
|
$list->set_query(" select * $sql_common $sql_where {$order_by} limit $from_record, $items ");
|
|
$list->set_is_page(true);
|
|
//$list->set_order_by($order_by);
|
|
//$list->set_from_record($from_record);
|
|
$list->set_view('it_img', true);
|
|
$list->set_view('it_id', true);
|
|
$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();
|
|
|
|
/*
|
|
// where 된 전체 상품수
|
|
$sql = " select count(*) as cnt $sql_common $sql_where ";
|
|
$row = sql_fetch($sql);
|
|
$total_count = $row['cnt'];
|
|
// 전체 페이지 계산
|
|
$total_page = ceil($total_count / $items);
|
|
*/
|
|
}
|
|
else
|
|
{
|
|
$i = 0;
|
|
$error = '<p class="sct_nofile">'.$ca['ca_skin'].' 파일을 찾을 수 없습니다.<br>관리자에게 알려주시면 감사하겠습니다.</p>';
|
|
}
|
|
|
|
if ($i==0)
|
|
{
|
|
echo '<div>'.$error.'</div>';
|
|
}
|
|
|
|
$query_string .= 'ca_id='.$ca_id;
|
|
$query_string .='&qsort='.$qsort.'&qorder='.$qorder;
|
|
echo get_paging($config['cf_write_pages'], $page, $total_page, $_SERVER['PHP_SELF'].'?'.$query_string.'&page=');
|
|
?>
|
|
</div>
|
|
|
|
</div>
|
|
<!-- } 검색결과 끝 -->
|
|
|
|
<?php
|
|
include_once('./_tail.php');
|
|
?>
|