<%@ page contentType="text/html; charset=euc-jp" %> <%@ page import = "java.util.*, java.io.*, java.text.*, java.sql.*, java.net.*" %> <%@ page errorPage="syserror_user.jsp" %> <%! private String NullConv( String val ) { try { val.equals("null"); return val; } catch ( Exception e ) { return ""; } } %> <% String cond = "", cond2 = "", str, query, bg; int count = 0, c = 0; ResultSet rs, cnt; HashMap hm1 = new HashMap(); HashMap hm2 = new HashMap(); HashMap hm3 = new HashMap(); HashMap hm4 = new HashMap(); hm1.put( request.getParameter("category_1"), "checked"); hm2.put( request.getParameter("category_2"), "checked"); hm3.put( request.getParameter("category_3"), "checked"); hm4.put( request.getParameter("category_4"), "checked"); db.open(); // フリーワード検索 String freeword = request.getParameter("freeword"); if ( freeword != null && freeword.getBytes().length > 0 ) { freeword = new String( freeword.getBytes("8859_1"), "EUC-JP"); } if ( freeword != null && freeword.getBytes().length > 0 ) { String word_cond = ""; StringTokenizer tkn = new StringTokenizer( freeword, " "); while ( tkn.hasMoreTokens()) { String st = tkn.nextToken(); query = "SELECT recipe_material.recipe_id "; query += "FROM recipe_material, recipe_procedure WHERE "; query += "recipe_material.recipe_id = recipe_procedure.recipe_id AND "; query += "(material like '%" + st + "%' OR procedure like '%" + st + "%') "; query += "GROUP BY recipe_material.recipe_id"; rs = db.select( query ); while ( rs.next()) { if ( cond2 != null && cond2.getBytes().length > 0 ) { cond2 += " OR "; } cond2 += "id = " + rs.getString(1); } if ( cond != null && cond.getBytes().length > 0 ) { cond += " AND "; } if ( cond2 != null && cond2.getBytes().length > 0 ) { cond += "( recipe.title like '%" + st + "%' OR " + cond2 + ")"; } else { cond += "recipe.title like '%" + st + "%'"; } cond2 = ""; } } // 調理時間検索 str = request.getParameter("category_1"); if ( str != null && str.getBytes().length > 0 ) { if ( cond != null && cond.getBytes().length > 0 ) { cond += " AND "; } cond += "category_1 = " + str; } // 難易度検索 str = request.getParameter("category_2"); if ( str != null && str.getBytes().length > 0 ) { if ( cond != null && cond.getBytes().length > 0 ) { cond += " AND "; } cond += "category_2 = " + str; } // ジャンル検索 str = request.getParameter("category_3"); if ( str != null && str.getBytes().length > 0 ) { if ( cond != null && cond.getBytes().length > 0 ) { cond += " AND "; } cond += "category_3 = " + str; } // 材料検索 str = request.getParameter("category_4"); if ( str != null && str.getBytes().length > 0 ) { if ( cond != null && cond.getBytes().length > 0 ) { cond += " AND "; } cond += "category_4 = " + str; } if ( cond.getBytes().length > 0 ) { cond += " AND "; } cond += "recipe.del is not true AND start_date <= current_timestamp"; if ( request.getQueryString() != null ) { query = "SELECT count(*) FROM recipe WHERE " + cond; cnt = db.select( query ); cnt.next(); count = cnt.getInt("count"); } 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") + "&"; } int offset, limit = 15, 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 = 15; String[] defDspCount = new String[]{"1","2","3","4","5","6","7","8","9"}; int pagecount = 0; String dspcount = null; for ( int i = 0; i < count; i+=l ) { pagecount++; if ( 10 > 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 ) < count ) { max = offset + limit; } else { max = count; } %> 〜本当のおいしさを〜いかりスーパー
トップページレシピ一覧>レシピ検索
詳細検索へ
ちょっとした工夫でおいしい料理を楽しもう
>>レシピ検索ヘルプ
■フリーワードで検索する
フリーワードで検索が可能です。キーワードの間にスペースを入れる事で、複数のキーワードで検索できます。


■条件を選択して検索する
以下の条件の中から、お探しのレシピの条件をチェックし、「以上の条件で検索」ボタンを押してください。
調理時間
<% query = "SELECT * FROM recipe_category WHERE del is not true AND id = 1 ORDER BY number"; rs = db.select(query); while (rs.next()) { %> <% } %>
> 指定無し
" <%=(String)hm1.get(rs.getString("number"))%>> <%=rs.getString("option")%>
難易度
<% query = "SELECT * FROM recipe_category WHERE del is not true AND id = 2 ORDER BY number"; rs = db.select(query); while (rs.next()) { %> <% } %>
> 指定無し
" <%=(String)hm2.get(rs.getString("number"))%>> <%=rs.getString("option")%>
ジャンル
<% query = "SELECT * FROM recipe_category WHERE del is not true AND id = 3 ORDER BY number"; rs = db.select(query); while (rs.next()) { %> <% } %>
> 指定無し
" <%=(String)hm3.get(rs.getString("number"))%>> <%=rs.getString("option")%>
材料
<% query = "SELECT * FROM recipe_category WHERE del is not true AND id = 4 ORDER BY number"; rs = db.select(query); while (rs.next()) { %> <% } %>
> 指定無し
" <%=(String)hm4.get(rs.getString("number"))%>> <%=rs.getString("option")%>
<% Enumeration key=request.getParameterNames(); if (key.hasMoreElements() == true && count == 0) { %>
その条件に当てはまるレシピはありません
<% } else if (count > 0) { %>

検索結果は投票の多い順に並んでいます。
検索結果<%=count%>件中 <%=offset+1%>〜<%=max%>件目表示 <%=PageNavi%>

<% query = "SELECT * FROM recipe WHERE " + cond + " ORDER BY vote DESC, id DESC LIMIT " + limit + " OFFSET " + offset; rs = db.select(query); while (rs.next()) { %> <% } %>
<% if (rs.getString("image_s").length()>0) { %> " width="60" height="40"> <% } %> ">●<%=rs.getString("title")%>

検索結果<%=count%>件中 <%=offset+1%>〜<%=max%>件目表示 <%=PageNavi%>


<% } %>


 
<% db.close(); %>