%@ Language=VBScript %> <%Option Explicit%> <% if session("LastNameOnTop") & "" = "" AND session("UserID") & "" <> "" then%> <%end if dim oRs, oConn, SQL, i, RecipCategs, Data, Dataexist dim SearchStr, whereclause, SplitStr, IDs, RecCategID dim PageNo, tens, starting, ending, totalRows, totalPages dim MainDataExist, MainData, thisstyle RecipCategs = Application("RecCategs"&lang) SearchStr = Request.Form("SearchStr") RecCategID = Request.Form("RecCategID") PageNo = Request("PageNo") : if PageNo & "" = "" then PageNo = 1 tens = Request("tens") : if tens & "" = "" then tens = 1 MainDataExist = -1 if lang = "GR" then templang = "" else templang = "EN" set oConn = Server.CreateObject("ADODB.Connection") oConn.open Application("Constr") set oRs = Server.createObject("ADODB.Recordset") if SearchStr & "" <> "" then IDs = "" whereclause = " WHERE " SplitStr = Split(SearchStr," ") for i=0 to ubound(SplitStr) whereclause = whereclause & " Word like '%" & SplitStr(i) & "%' OR" next '=== Getting RecipeIDs ========= SQL = "Select DISTINCT RecipeID from RecipeHits where WordID in (Select WordID from RecipeWords " & left(whereclause, len(whereclause)-3) &")" oRs.open SQL, oConn, 3,1,1 while not oRs.EOF IDs = IDs & oRs("RecipeID") & "," oRs.MoveNext wend if Instr(IDs,",") >0 then IDs = left(IDs,len(IDs)-1) oRs.close if IDs & "" = "" then IDs = -1 SQL = "SearchRec '" & IDs & "', '" & templang &"', '" & RecCategID & "'," & PageSize & ", " & PageNo oRs.open SQL, oConn, 0, 1, 1 if oRs.state=0 then oRs.open SQL, oConn, 3, 1, 1 if oRs.EOF = false then totalRows = oRs("TotalRecs") if totalRows = 0 then MainDataExist = 0 else totalRows = oRs("TotalRecs") MainDataExist = 1 MainData = oRs.GetRows() totalPages = totalRows \ PageSize if totalRows mod PageSize > 0 then totalPages = totalPages + 1 end if oRs.close starting = ((tens-1)*10)+1 : ending = starting + 9 end if SQL = "Select top 1 RecipeID, RecipeName"&templang&", dbo.GetLessText(RecipeInfo"&templang&",30) as RecipeInfo, IsNull(RecipePhotos,'default.jpg'), IsNull(RecipeThumbs,'default.jpg'), RecipeMaterial"&templang&" from Recipe where RecipeShow=1 order by NewID()" oRs.open SQL, oConn, 3,1,1 if oRs.EOF = false then Data = oRs.GetRows() Dataexist = 1 end if GoToPage = "RecSearch.asp" menu = "2" %>