<% if request("action") <> "complete" then %>
Search by one of the following methods:
Keyword Search:
Category Search:
Recipe Name:
Only include vegetarian recipes
<% SQL = "SELECT name, entry_id, ROTW FROM recipe_tbl WHERE rotw <= NOW() ORDER BY ROTW DESC" Set RS = server.createObject("ADODB.recordset") rs.open SQL, conn rs.movefirst Response.write "


NTI's Recipe of the Week:
"&rs("name")&"

" rs.close set rs=nothing conn.close set conn= nothing %>

 

<%else '*********************bottom part of page is for precessing request and returning result********** '************************************************************************************************** '************************************************************************************************** Function CleanString(sqlValue) CleanString = replace(sqlValue, "'", "''") End function vegetarian = request.form("vegetarian") category = cleanstring(request.form("category")) keywords = Cleanstring(request.form("keywords")) name = Cleanstring(request.form("name")) if name = "" and category = "" and keywords = "" then flag = "none" response.write "You must make some selection for the search to work." end if if flag <> "none" then SQL = "SELECT entry_id, name FROM recipe_tbl WHERE " end if if category <> "" then SQL = SQL & "Category = '" & category & "' " else SQL = SQL end if if keywords <> "" or name <> "" then ' one of these is filled in if category <> "" then ' we need an AND SQL = SQL & " AND " else SQL = SQL end if if keywords <> "" then SQL = SQL & "keywords LIKE '%" & keywords & "%' " else SQL = SQL 'There were no keywords end if if name <> "" then if keywords <> "" then 'keywords took the last AND SQL = SQL & " AND name LIKE '%" & name & "%' " else SQL = SQL & " name LIKE '%" & name & "%' " end if end if end if if vegetarian = "TRUE" then SQL = SQL & " AND boolean_field = TRUE ORDER BY entry_id DESC;" else SQL = SQL & " ORDER BY entry_id DESC;" end if 'response.write category & ", " & keywords & ", " & name & ", veggie = " & vegetarian & "
" 'response.write SQL Set Conn=server.createobject("ADODB.connection") Conn.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\") & "\data\NothingToIt.mdb;UID=;PWD=;" SET RS=server.createObject("ADODB.recordset") rs.open SQL, CONN If not rs.eof then response.write "" while not rs.eof response.write "" rs.movenext wend response.write "
"& rs("name") &"
" else response.write "No matches, please search again." end if rs.close set rs=nothing conn.close set conn=nothing end if%>