'找茶葉口味' ); if(isset($_GET['q'])) redirect("{$php_self}?f={$filter}&c={$q}"); $website_sub_title = '找茶葉口味'; $filter_define = $FIND_CATEGORY; if(isset($q)) { $path["{$php_self}?f={$filter}&c={$q}"] = $FIND_CATEGORY[$q - 1][0]; if(! isset($FIND_CATEGORY[$q - 1])) redirect("$php_self?f=$filter"); $condition = "FIND_IN_SET('" . addslashes($FIND_CATEGORY[$q - 1][0]) . "', `category`)"; } break; case 'price': $path = array( "{$php_self}?f={$filter}" => '找茶葉價格' ); if(isset($_GET['q'])) redirect("{$php_self}?f={$filter}&c={$q}"); $website_sub_title = '找茶葉價格'; $filter_define = $FIND_PRICE; if(isset($q)) { $path["{$php_self}?f={$filter}&c={$q}"] = $FIND_PRICE[$q - 1][0]; if(! isset($FIND_PRICE[$q - 1])) redirect("$php_self?f=$filter"); $q1 = (int) $FIND_PRICE[$q - 1][1]; $q2 = (int) $FIND_PRICE[$q - 1][2]; $condition = "(`price` BETWEEN $q1 AND $q2)"; } break; case 'query': $path = array( "{$php_self}?f={$filter}&q=" . urlencode($q) => '查詢結果' ); if(! isset($q)) redirect('./'); $q = trim($q); if(strlen($q) == 0) redirect('./'); if(isset($BRAND[strtoupper($q)]) && $BRAND[strtoupper($q)]['enable'] == 1) redirect("./brand.php?id=" . strtoupper($q)); $website_sub_title = "尋找商品:$q"; $sql = "SELECT `id` FROM `query_log` WHERE `ip`='" . GetIP() . "' AND `time` > '" . GetTime(-10) . "' AND `query_string`='" . addslashes($q) . "'"; if($result = mysql_query($sql)) { if(mysql_num_rows($result) == 0) { $log_data = mysql_create_insert_pair(array( 'member_id' => (isLogin() ? $_SESSION['member']['id'] : 0), 'query_string' => $q, 'ip' => GetIP(), 'time' => GetTime() )); $sql = "INSERT INTO `query_log` ({$log_data[0]}) VALUE ({$log_data[1]})"; @mysql_query($sql); } mysql_free_result($result); } get_brands(); $q_split = preg_split('/(\s|,|\+)+/', $q); $sub_conditions = array(); foreach($q_split as $i => $qq) { $brand_id = ''; foreach($BRAND as $id => $brand) { if(preg_match("/" . preg_quote($qq, '/') . "/i", $brand['name'])) { $brand_id = $id; break; } } $qq = addslashes($qq); $sub_conditions[] = '(' . implode(' OR ', array( "`id`='$qq'", "`brand`='$brand_id'", "`name` LIKE '%$qq%'", "`sub_name` LIKE '%$qq%'", "`content` LIKE '%$qq%'", "`origin` LIKE '%$qq%'", "`type` LIKE '%$qq%'", "`category` LIKE '%$qq%'", "`ferment` LIKE '%$qq%'", "`bake` LIKE '%$qq%'", "`usetype` LIKE '%$qq%'", "`tag_origin` LIKE '%$qq%'" )) . ')'; } $condition = '(' . implode(' AND ', $sub_conditions) . ')'; break; default: redirect('./'); } if(isset($condition)) { $sql = "SELECT * FROM `products` WHERE $condition AND `enable`=1 ORDER BY `price`"; } else if($filter == 'category') { $sql = "SELECT * FROM `products` WHERE `enable`=1 ORDER BY `brand`, `price`"; } else { $sql = "SELECT * FROM `products` WHERE `enable`=1 ORDER BY `price`"; } $result = mysql_query($sql) or mysql_err(); $products = array(); while($row = mysql_fetch_assoc($result)) { $products[] = $row; } mysql_free_result($result); mysql_close(); html_header_1('', array(), array('find.css'), $website_sub_title); if(isset($filter_define)) { ?>
$f) { ?>
查詢 的結果,共 0 項商品