%@ page contentType="text/html; charset=euc-jp" %> <%@ page import = "java.util.*, java.io.*, java.text.*, java.sql.*, java.net.*, java.lang.Character.*, java.util.regex.*" %> <%@ page errorPage="/syserror.jsp" %> <%! private boolean StrNumberCheck (String val) throws UnsupportedEncodingException { if(val!=null){ Pattern pattern = Pattern.compile("[^0-9]"); Matcher matcher = pattern.matcher(val); if (matcher.find() == true) { return false; } } return true; }private String NumFormat(String num) { int n = Integer.valueOf(num).intValue(); DecimalFormat NumFormat = new DecimalFormat("###,###"); return NumFormat.format(n); } %> <% String cond = "", str, query, bg; int c = 0; String freeword = request.getParameter("freeword"); if (freeword != null && !freeword.equals("")) { cond += "("; cond += "lower(product) LIKE '%" + freeword + "%' OR "; cond += "lower(mini_comment) LIKE '%" + freeword + "%' OR "; cond += "lower(short_comment) LIKE '%" + freeword + "%' OR "; cond += "lower(appeal_comment_1) LIKE '%" + freeword + "%' OR "; cond += "lower(appeal_comment_2) LIKE '%" + freeword + "%' OR "; cond += "lower(special_comment) LIKE '%" + freeword + "%' OR "; cond += "lower(special_title) LIKE '%" + freeword + "%' OR "; cond += "lower(user_voice_1) LIKE '%" + freeword + "%' OR "; cond += "lower(user_voice_2) LIKE '%" + freeword + "%' OR "; cond += "lower(user_voice_3) LIKE '%" + freeword + "%' OR "; cond += "lower(gourmet_comment) LIKE '%" + freeword + "%' OR "; cond += "lower(search_keyword) LIKE '%" + freeword + "%'"; cond += ")"; } freeword = new String(freeword.getBytes("8859_1"), "EUC-JP"); String price = ""; String price1 = request.getParameter("price1"); String price2 = request.getParameter("price2"); if (StrNumberCheck(price1)==false||StrNumberCheck(price2)==false) { String errmsg="価格は半角数字で入力してください"; session.setAttribute("ErrMsg", errmsg); %> <% } if (price1 != null && !price1.equals("")) { price += NumFormat(request.getParameter("price1")) + "円以上"; if (cond != null && !cond.equals("")) { cond += " AND "; } cond += "price >= '" + price1 + "'"; } if (price2 != null && !price2.equals("")) { if (!price.equals("")) { price += " 〜 "; } price += NumFormat(request.getParameter("price2")) + "円以下"; if (cond != null && !cond.equals("")) { cond += " AND "; } cond += "price <= '" + price2 + "'"; } String category = "", c_cond = ""; Pattern pattern1 = Pattern.compile("x$"); Pattern pattern2 = Pattern.compile("y$"); Enumeration key=request.getParameterNames(); while(key.hasMoreElements()) { String tag = (String) (key.nextElement()); Matcher matcher1 = pattern1.matcher(tag); if (matcher1.find() == true) { continue; } Matcher matcher2 = pattern2.matcher(tag); if (matcher2.find() == true) { continue; } if (tag.equals("freeword") || tag.equals("price1") || tag.equals("price2") || tag.equals("submit") || tag.equals("offset")) { continue; } String val = request.getParameter(tag); category += val + " "; if (!c_cond.equals("")) { c_cond += " OR "; } c_cond += "category_id_1 = '" + tag + "' OR "; c_cond += "category_id_2 = '" + tag + "' OR "; c_cond += "category_id_3 = '" + tag + "'"; } if (!c_cond.equals("")) { if (cond != null && !cond.equals("")) { cond += " AND "; } cond += "(" + c_cond + ")"; } if (cond.equals("")) { String errmsg="検索条件が設定されていません"; session.setAttribute("ErrMsg", errmsg); %> <% } //-- [start modified 2003-12-26] --// //Calendar cal = Calendar.getInstance(); //SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd"); //String date = df.format(cal.getTime()); cond += " AND del is not true"; cond += " AND (start_date <= current_timestamp or start_date is null)"; cond += " AND (end_date >= current_timestamp or end_date is null)"; //cond += " AND (start_date is null OR start_date <= '" + date + "')"; //cond += " AND (end_date is null OR end_date >= '" + date + "')"; cond += " AND (inventory_figures > 0 OR inventory_figures is null)"; //-- [end modified 2003-12-26] --// db.open(); query = "SELECT count(*) FROM goods WHERE " + cond; query = new String(query.getBytes("8859_1"), "EUC-JP"); ResultSet cnt = db.select(query); cnt.next(); int count = cnt.getInt("count"); if (count == 0) { String errmsg="この条件にあてはまる商品はありません"; session.setAttribute("ErrMsg", errmsg); %> <% } String uriQuery = "", tmpStr; Enumeration queryList = request.getParameterNames(); while(queryList.hasMoreElements()) { String k = (String) (queryList.nextElement()); if (k.equals("offset") || k.equals("submit")) { continue; } tmpStr = new String(request.getParameter(k).getBytes("8859_1"), "EUC-JP"); // uriQuery += k + "=" + URLEncoder.encode(tmpStr, "Shift_JIS") + "&"; uriQuery += k + "=" + URLEncoder.encode(tmpStr, "EUC-JP") + "&"; } int offset, limit = 25, max; String uri = request.getRequestURI() + "?" + uriQuery; String prev = "", next = "", box = ""; if(request.getParameter("offset") != null) { offset = Integer.parseInt(request.getParameter("offset")); } else { offset = 0; }int l = 25; String[] defDspCount = new String[]{"1","2","3","4","5","6","7","8","9"}; int pagecount = 0; String dspcount = null; for(int i=0; i pagecount) { dspcount = defDspCount[pagecount-1]; } else { dspcount = new Integer(pagecount).toString(); } if(offset>i) { box += "" + dspcount + " "; prev = "<前ページ"; } else if(offset+l<=i) { box += "" + dspcount + " "; next = "次ページ>"; } else { box += dspcount + " "; } } String PageNavi = prev + "[" + box + "]" + next; if ((offset + limit)"); ResultSet rs = db.select(query); category = new String(category.getBytes("8859_1"), "EUC-JP"); %> 〜本当のおいしさを〜いかりスーパー トップページ>条件を設定して商品を検索>検索結果 あなたが指定した検索条件は以下のとおりです。検索をやり直す場合はこちら。 フリーワード入力: <%=freeword%> 価格: <%=price%> ジャンル指定: <%=category%> 検索の結果<%=count%>商品がヒットしました 検索結果<%=count%>件中 <%=offset+1%>〜<%=max%>件目表示 <%=PageNavi%> <% while(rs.next()) { %> <% if (c % 2 == 1) { bg = ""; } else { bg = "#F4F4F4"; } %> " target="_top">" width="60" height="40" alt="商品画像" border="0"> " target="_top"><%=rs.getString("product")%> <% c ++; %> <% } %> 検索結果<%=count%>件中 <%=offset+1%>〜<%=max%>件目表示 <%=PageNavi%> <% db.close(); %>