현재는 선택한 값과 동일한 데이터만 검색 출력이 되는데요
원하는것은 예를들어 "3년이상" 을 선택하고 검색을 하면 그 위에 존재하는 값도 출력이 되도록
하고 싶습니다.
"3년이상"을 선택하고 검색을 하면
5년이상
7년이상
10년이상
.
.
.
으로 등록된 값은 다 나오는것이죠..
Copy
<select name="wr_3" id="wr_3" style="padding:3px; border:1px solid #ccc"> <option value="">경력</option> <option value="1년이상" <?if ($wr_3 == '1년이상') echo "selected" ?>>1년이상</option> <option value="3년이상" <?if ($wr_3 == '3년이상') echo "selected" ?>>3년이상</option> <option value="5년이상" <?if ($wr_3 == '5년이상') echo "selected" ?>>5년이상</option> <option value="7년이상" <?if ($wr_3 == '7년이상') echo "selected" ?>>7년이상</option> <option value="10년이상" <?if ($wr_3 == '10년이상') echo "selected" ?>>10년이상</option> <option value="12년이상" <?if ($wr_3 == '12년이상') echo "selected" ?>>12년이상</option> <option value="15년이상" <?if ($wr_3 == '15년이상') echo "selected" ?>>15년이상</option> <option value="17년이상" <?if ($wr_3 == '17년이상') echo "selected" ?>>17년이상</option> <option value="20년이상" <?if ($wr_3 == '20년이상') echo "selected" ?>>20년이상</option> <option value="25년이상" <?if ($wr_3 == '25년이상') echo "selected" ?>>25년이상</option> <option value="30년이상" <?if ($wr_3 == '30년이상') echo "selected" ?>>30년이상</option> </select>
아래 출력 함수를 적용해봐도 여전히 선택된 값만 출력이 되어서 재질문 올립니다.
어디가 잘못되었을까요..
Copy
// 추가 및 변경 함수 시작$arr_search = array();for($j = 1; $j < 11; $j++){ if($_GET["wr_".$j] && strlen($_GET["wr_".$j]) > 0){ $qstr .= "&wr_".$j."=".urlencode($_GET["wr_".$j]); }} // 검색 구문을 얻는다.//function get_sql_search($search_ca_name, $search_field, $search_text, $search_operator=false)function get_sql_search2($search_ca_name, $search_field, $search_text, $search_operator='and',$search_arr=''){ global $g5; $str = ""; if ($search_ca_name) $str = " ca_name = '$search_ca_name' "; $search_text = trim($search_text); if (!$search_text && !$search_arr) return $str; if(count($search_arr[name]) > 0){ $se_flag = 0; for($j = 0; $j < count($search_arr[name]); $j++){ //print_r2($search_arr); if(is_array($search_arr[val][$j])){ $str2 = ""; for($x = 0; $x < count($search_arr[val][$j]);$x++){ $str2 = append_sql($str2, " or ", " {$search_arr[name][$j]} like '%{$search_arr[val][$j][$x]}%' "); } $str2 = " (".$str2.") "; $str = append_sql($str, " and", $str2); }else if(strlen($search_arr[val][$j]) > 0 && $search_arr[val][$j] ){ $str = append_sql($str, " and ", " {$search_arr[name][$j]} = '{$search_arr[val][$j]}' "); } } } // 쿼리의 속도를 높이기 위하여 ( ) 는 최소화 한다. $op1 = ""; // 검색어를 구분자로 나눈다. 여기서는 공백 $s = array(); $s = explode(" ", $search_text); if(count($s) > 0 && strlen($s[0]) > 0 ){ if ($str) $str .= " and "; // 검색필드를 구분자로 나눈다. 여기서는 + //$field = array(); //$field = explode("||", trim($search_field)); $tmp = array(); $tmp = explode(",", trim($search_field)); $field = explode("||", $tmp[0]); $not_comment = $tmp[1]; $str .= "("; for ($i=0; $i<count($s); $i++) { // 검색어 $search_str = trim($s[$i]); if ($search_str == "") continue; // 인기검색어 /* $sql = " insert into $g5[popular_table] set pp_word = '$search_str', pp_date = '$g5[time_ymd]', pp_ip = '$_SERVER[REMOTE_ADDR]' "; sql_query($sql, FALSE); */ if(count($field) > 0){ $str .= $op1; $str .= "("; $op2 = ""; for ($k=0; $k<count($field); $k++) { // 필드의 수만큼 다중 필드 검색 가능 (필드1+필드2...) $str .= $op2; switch ($field[$k]) { case "mb_id" : case "wr_name" : $str .= " $field[$k] = '$s[$i]' "; break; case "wr_hit" : case "wr_good" : case "wr_nogood" : $str .= " $field[$k] >= '$s[$i]' "; break; // 번호는 해당 검색어에 -1 을 곱함 case "wr_num" : $str .= "$field[$k] = ".((-1)*$s[$i]); break; // LIKE 보다 INSTR 속도가 빠름 default : if (preg_match("/[a-zA-Z]/", $search_str)) $str .= "INSTR(LOWER($field[$k]), LOWER('$search_str'))"; else { if(strstr($field[$k], '년이상')){ $search_str = preg_replace("/[^0-9]*/s", "", $search_str); $field_str = explode('년이상', trim($field[$k])); $str .= "("; $str_add = ""; foreach($field_str as $val){ $num = preg_replace("/[^0-9]*/s", "", $val); if($num >= $search_str) { $num = $num.'년이상'; $str_add .= "INSTR($field[$k], '$num') or "; } } $str .= substr($str_add, 0, -3); $str .= ")"; } else { $str .= "INSTR($field[$k], '$search_str')"; } } } $op2 = " or "; } $str .= ")"; } //$op1 = ($search_operator) ? ' and ' : ' or '; $op1 = " $search_operator "; } $str .= " ) "; } if ($not_comment){ $str .= " and wr_is_comment = '0' "; } return $str;} function append_sql($sql, $appender, $text) { if(strlen($sql) > 0) { $sql = $sql.$appender.$text; } else { $sql = $text; } return $sql;}// 추가 및 변경 함수 끝 $arr_search = array();for($j = 1; $j < 11; $j++){ if($_GET["wr_".$j] && strlen($_GET["wr_".$j]) > 0){ $arr_search[name][] = "wr_".$j; $arr_search[val][] = $_GET["wr_".$j]; }}
답변 1개
채택된 답변
+20 포인트
2015-08-26 (수) 16:59:32
제작의뢰 내용 확인후 댓글 달아드립니다.
검색식 조건이 잘못된게 맞는것 같습니다.
"년이상"은...구지 db에 저장되지 않아도 될것 같습니다.
답변을 작성하려면 로그인이 필요합니다.