<% 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 " 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 DIM RS DIM CONN 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 %>