|
Here's the whole result page - thank you
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="dwzone_search_conn_0.asp"--> <% '****************************** ' START ADVANCED SEARCH '****************************** pageId = "0" pageBack = "/Book_Mountaineering.asp?" & request.form if request("dwzone_FormField") = "" then FormField = split(session("dwzone_FormField"),",") SearchField = split(session("dwzone_SearchField"),",") TypeField = split(session("dwzone_TypeField"),",") DisplayField = split(session("dwzone_DisplayField"),",") StrSQL = session("dwzone_StrSQL") ValueToSearch = split(session("dwzone_ValueToSearch"),",") else FormField = split(request.form("dwzone_FormField"),",") SearchField = split(request.form("dwzone_SearchField"),",") TypeField = split(request.form("dwzone_TypeField"),",") DisplayField = split(request.form("dwzone_DisplayField"),",") StrSQL = request.form("dwzone_StrSQL") cong = "" for J=0 to ubound(FormField) tmpValueToSearch = tmpValueToSearch & cong & Trim(request.form(FormField(J))) cong = "," next ValueToSearch = split(tmpValueToSearch,",") session("dwzone_FormField") = request.form("dwzone_FormField") session("dwzone_SearchField") = request.form("dwzone_SearchField") session("dwzone_TypeField") = request.form("dwzone_TypeField") session("dwzone_DisplayField") = request.form("dwzone_DisplayField") session("dwzone_StrSQL") = request.form("dwzone_StrSQL") session("dwzone_ValueToSearch") = tmpValueToSearch end if ThisClass = "DW_Cell_1" 'Where and Having Clause Set Conn = Server.CreateObject("AdoDb.Connection") Set RS = Server.CreateObject("AdoDb.Recordset") Conn.Open MM_Glacier_STRING Rs.open StrSQL,Conn whereCong = "" havingCong = "" whereClause = "" havingClause = "" for J=0 to ubound(FormField) if lcase(SearchField(J)) <> "dw_0" and ValueToSearch(J) <> "" then if fieldExists(ValueToSearch(J)) then whereClause = whereClause & whereCong & retValueToSearch(SearchField(J),request(FormField(J) & "_DwFilter"),removeSpecialChar(ValueToSearch(J)),J) whereCong = " AND " else havingClause = havingClause & havingCong & retValueToSearch(SearchField(J),request(FormField(J) & "_DwFilter"),removeSpecialChar(ValueToSearch(J)),J) havingCong = " AND " end if end if next RS.close StrSQL = composeSql(StrSQL,whereClause,havingClause)
pageNumber = CInt(Request("pageNumber")) if PageNumber = 0 then pageNumber = 1 PageSize = 10 Rs.open StrSQL,Conn NumRec = 0 while not Rs.eof NumRec = NumRec +1 Rs.MoveNext wend Rs.close Rs.open StrSQL,Conn if (NumRec / PageSize) - int(NumRec / PageSize) <> 0 then TotalPage = int(NumRec / PageSize) + 1 else TotalPage = int(NumRec / PageSize) end if if not Rs.eof then for J=1 to (CInt(pageNumber) - 1 ) * PageSize Rs.MoveNext next end if FirstPage = "1" PreviousPage = pageNumber - 1 if PreviousPage < 1 then PreviousPage = 1 end if NextPage = pageNumber + 1 if NextPage > TotalPage then NextPage = TotalPage end if Lastpage = TotalPage
'****************************** ' END ADVANCED SEARCH '******************************
%> <html> <head> <title>Search Result Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="advSearch_<%=pageId%>.css" type="text/css"> </head>
<body bgcolor="#00cc99"> <!-- DO NOT MOVE! The following AllWebMenus code must always be placed right AFTER the BODY tag--> <!-- ******** BEGIN ALLWEBMENUS CODE FOR Glacier ******** --> <span id='xawmMenuPathImg-Glacier' style='position:absolute;top:-50px'><img name='awmMenuPathImg-Glacier' id='awmMenuPathImg-Glacier' src='../awmmenupath.gif' alt=''></span> <script type='text/javascript'>var MenuLinkedBy='AllWebMenus [2]', awmBN='DW'; awmAltUrl='';</script> <script src='../Glacier.js' language='JavaScript1.2' type='text/javascript'></script> <script type='text/javascript'>awmBuildMenu();</script> <!-- ******** END ALLWEBMENUS CODE FOR Glacier ******** --> <div align="center"><img src="../Pics/HeaderFinalf.jpg" width="751" height="71"> <br> <table width="750" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td><style type="text/css">.awmAnchor {position:relative;z-index:0}</style><span id='awmAnchor-Glacier' class='awmAnchor'> </span></td> </tr> <tr> <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Search Result Page</strong></font></td> </tr> </table> </div> <table width="750" border="0" align="center" cellpadding="5" cellspacing="0"> <% if Rs.eof Then %> <tr> <td align="left"><div align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Sorry, no records in the database matched your search parameters. Click Back and try again. </font></div> </td> </tr> <% End If %> <% Line = 0 do while not Rs.eof Line = Line + 1 %> <tr> <td class="<%=ThisClass%>"> </td> <% for J=0 to ubound(FormField) %> <% if clng(DisplayField(J)) = -1 then %> <td align="left" valign="top" class="<%=ThisClass%>" wrap><%=Rs(SearchField(J))%></td> <% end if next %> </tr> <% if ThisClass = "DW_Cell_1" then ThisClass = "DW_Cell_2" else ThisClass = "DW_Cell_1" end if if Line = PageSize then exit do end if Rs.MoveNext loop %> </table> <br> <% if TotalPage <> 0 then %> <table border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#00cc99"> <tr> <td><table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff"> <tr align="center"> <td width="10" align="left" > </td> <td width="100" align="left" ><a href="<%=pageBack%>"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Back</strong></font></a></td> <% if TotalPage > 1 then %> <td width="100" ><a href="dwzone_search_result_<%=pageId%>.asp?PageNumber=<%=FirstPage & createQueryString()%>" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>First Page</strong></font></a></td> <td width="100" ><a href="dwzone_search_result_<%=pageId%>.asp?PageNumber=<%=PreviousPage & createQueryString()%>" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Previous Page</strong></font></a><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong></td> <td width="100" ><a href="dwzone_search_result_<%=pageId%>.asp?PageNumber=<%=NextPage & createQueryString()%>" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Next page</strong></font></a><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font></strong></td> <td width="100" ><a href="dwzone_search_result_<%=pageId%>.asp?PageNumber=<%=LastPage & createQueryString()%>" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Last page</strong></font> </a></td> <% end if %> <td width="100" align="right" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Page <%=PageNumber%> of <%=TotalPage%></strong></font></td> <td width="10" align="right" > </td> </tr> </table> </td> </tr> </table> <% else %> <br> <br> <br> <br> <br> <table border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#00CC99"> <tr> <td><table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#00CC99"> <tr align="center"> <td width="100" align="center" ><a href="<%=pageBack%>" ><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Back</strong></font></a></td> </tr> </table> </td> </tr> </table> <% end if %> </body> </html>
<% Rs.close Conn.close set Rs = nothing set Conn = nothing function retValueToSearch(Field,Operator,Str,Id) select case Operator case "1" 'All words valori = split(Str," ") congToSearch = " AND " Op = "1" case "2" 'One of them valori = split(Str," ") congToSearch = " OR " Op = "1" case else 'Exact Phrase Dim valori(0) valori(0) = Str congToSearch = "" Op = "1" end select myCong = "" for x = 0 to ubound(valori) if clng(TypeField(Id)) = 1 or not isNumeric(Str) then 'String value if Op = "1" then retStr = retStr & myCong & Field & " LIKE '%" & stringa(valori(x)) & "%'" else retStr = retStr & myCong & Field & " = '" & stringa(valori(x)) & "'" end if else 'Numeric Value retStr = retStr & myCong & Field & " = " & valori(x) end if myCong = congToSearch next retValueToSearch = "(" & retStr & ")" end function Function Stringa (Str) Stringa = Replace(Replace(Str,"'","''"), "|","' & CHR(124) & '") End function function removeSpecialChar(Str) newStr = replace(replace(Str,"'",""),chr(34),"") while instr(newStr," ")>0 newStr = replace(newStr," "," ") wend removeSpecialChar = newStr end function function fieldExists(FLD) on error resume next tmp = RS(FLD) on error goto 0 if err.number = 0 then ris = -1 else ris = 0 end if fieldExists = ris end function function composeSql(Str_SQL,where_Clause,having_Clause) startWhere = instr(1,Str_SQL,"WHERE",vbtextcompare) startGroup = instr(1,Str_SQL,"GROUP BY",vbtextcompare) startHaving = instr(1,Str_SQL,"HAVING",vbtextcompare) startOrder = instr(1,Str_SQL,"ORDER BY",vbtextcompare) selectStr = "" groupStr = "" orderStr = "" if startWhere > 0 then selectStr = left(Str_SQL,startWhere-1) elseif startGroup > 0 then selectStr = left(Str_SQL,startGroup-1) elseif startHaving > 0 then selectStr = left(Str_SQL,startHaving-1) elseif startOrder > 0 then selectStr = left(Str_SQL,startOrder-1) else selectStr = StrSQL end if if startGroup > 0 then if startHaving > 0 then groupStr = mid(Str_SQL,startGroup,startHaving-1) elseif startOrder > 0 then groupStr = mid(Str_SQL,startGroup,startOrder-1) else groupStr = mid(Str_SQL,startGroup) end if end if if startHaving > 0 then if startOrder > 0 then orderStr = mid(Str_SQL,startHaving,startOrder-1) else orderStr = mid(Str_SQL,startHaving) end if end if if where_Clause <> "" then where_Clause = " WHERE " & where_Clause end if if having_Clause <> "" then having_Clause = " HAVING " & having_Clause end if composeSql = selectStr & " " & where_Clause & " " & groupStr & " " & having_Clause & " " & orderStr end function function createQueryString() retStr = "" for J=0 to ubound(FormField) if request(FormField(J) & "_DwFilter") <> "" then retStr = retStr & "&" & FormField(J) & "_DwFilter=" & request(FormField(J) & "_DwFilter") end if next createQueryString = retStr end function %> |
|
|
|
|