% Option Explicit %>
<%
Response.Buffer = True
'Dimension variables
Dim rsSearchResults 'database Recordset Variable
Dim intRecordPositionPageNum 'Holds the record position
Dim intRecordLoopCounter 'Loop counter for displaying the database records
Dim lngTotalRecordsFound 'Holds the total number of records in the database
Dim lngTotalNumPages 'holds the total number of pages in the database
Dim intLinkPageNum 'Holds the page number to be linked to
Dim intLoopCounter 'Holds the loop counter number
Dim sarySearchWord 'Holds the keywords for the URL
Dim strSearchKeywords 'Holds the keywords to be searched
Dim intSQLLoopCounter 'Loop counter for the loop for the sql query
Dim intSearchWordLength 'Holds the length of the word to be searched
Dim blnSearchWordLenthOK 'Boolean set to false if the search word length is not OK
Dim intRecordDisplayFrom 'Holds the number of the search result that the page is displayed from
Dim intRecordDisplayedTo 'Holds the number of the search result that the page is displayed to
'If this is the first time the page is displayed then the page position is set to page 1
If Request.QueryString("PagePosition") = "" Then
intRecordPositionPageNum = 1
'Else the page has been displayed before so the page postion is set to the Record Position number
Else
intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If
'Read in all the search words into one variable
strSearchKeywords = Trim(Request.QueryString("search"))
'If the use has not entered a value then let the search words variable contain a space (chr10)
If strSearchKeywords = "" Then strSearchKeywords = chr(10)
'Replace any less than or greater than signs with the HTML equivalent (stops people entering HTML tags)
strSearchKeywords = Replace(strSearchKeywords, "<", "<")
strSearchKeywords = Replace(strSearchKeywords, ">", ">")
strSearchKeywords = Replace(strSearchKeywords, "'", "''")
'Read in the search words to be searched
sarySearchWord = Split(Trim(strSearchKeywords), " ")
'Return the tow '' back to one' for displaying on the screen
strSearchKeywords = Replace(strSearchKeywords, "''", "'")
'Initalise the word search length variable
blnSearchWordLenthOK = True
'Loop round to check that each word to be searched has more than the minimum word length to be searched
For intLoopCounter = 0 To UBound(sarySearchWord)
'Initialise the intSearchWordLength variable with the length of the word to be searched
intSearchWordLength = Len(sarySearchWord(intLoopCounter))
'If the word length to be searched is less than or equal to min word length then set the blnWordLegthOK to false
If intSearchWordLength <= intMinuiumSearchWordLength Then
blnSearchWordLenthOK = False
End If
Next
'Create a recordset object
Set rsSearchResults = Server.CreateObject("ADODB.Recordset")
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblWebsites.* FROM tblWebsites "
'Get the mode to decide how we are going to buid the SQL Query
Select Case Request.QueryString("mode")
'If the user has selected to search any words then intalise the strSQL statement to search for any words in the database
Case "anywords"
'Search for the first search word in the URL titles
strSQL = strSQL & "WHERE Title LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search for each search word entered by the user
For intSQLLoopCounter = 0 To UBound(sarySearchWord)
strSQL = strSQL & " OR Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'Order the search results by the number of click through Hits decending (most popular sites first)
strSQL = strSQL & " ORDER By Rating DESC, No_of_ratings DESC, Hits DESC;"
'If the user has selected to search for all words then intalise the strSQL statement to search for entries containing all the search words
Case "allwords"
'Search for the first word in the URL titles
strSQL = strSQL & "WHERE (Title LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search the URL titles for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'OR if the search words are in the keywords
strSQL = strSQL & ") OR (Keywords LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search the URL keywords for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'Or if the search words are in the title
strSQL = strSQL & ") OR (Description LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search the URL description for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'Order the search results by the number of click through Hits decending (most popular sites first)
strSQL = strSQL & ") ORDER By Rating DESC, No_of_ratings DESC, Hits DESC;"
Case "category"
'Search for the first search word in the URL titles
strSQL = strSQL & "WHERE (Title LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search for each search word entered by the user
For intSQLLoopCounter = 0 To UBound(sarySearchWord)
strSQL = strSQL & " OR Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
strSQL = strSQL & ") AND category LIKE '" & Request.QueryString("ref") & "%'"
'Order the search results by the number of click through Hits decending (most popular sites first)
strSQL = strSQL & " ORDER By Rating DESC, No_of_ratings DESC, Hits DESC;"
'If the user has selected to see newly enetred URL's then order the search results by date decending
Case "new"
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT TOP " & intRecordsPerPage & " tblWebsites.* FROM tblWebsites"
strSQL = strSQL & " ORDER By SiteIDNo DESC;"
End Select
'Query the database with the strSQL statement
rsSearchResults.Open strSQL, strCon, 3
'Count the number of records found
lngTotalRecordsFound = CLng(rsSearchResults.RecordCount)
'If this is a random URL then strip all the other URL's and only leave one remaining URL
If Request.QueryString("submit") = "Random Search" and NOT rsSearchResults.EOF Then
'Randomise system timer
Randomize Timer
'Move to a random record in the recordset
rsSearchResults.Move CLng(RND * lngTotalRecordsFound) - 0.5
'Filter out all the other records
rsSearchResults.Filter = "SiteIDNo =" & rsSearchResults("SiteIDNO")
Else
'Set the number of records to display on each page by the constant set at the top of the script
rsSearchResults.PageSize = intRecordsPerPage
'Get the page number record poistion to display from
IF NOT rsSearchResults.EOF Then rsSearchResults.AbsolutePage = intRecordPositionPageNum
'Count the number of pages the search results will be displayed on calculated by the PageSize attribute set above
lngTotalNumPages = CLng(rsSearchResults.PageCount)
'Calculate the the record number displayed from and to on the page showing
intRecordDisplayFrom = (intRecordPositionPageNum - 1) * intRecordsPerPage + 1
intRecordDisplayedTo = (intRecordPositionPageNum - 1) * intRecordsPerPage + intRecordsPerPage
If intRecordDisplayedTo > lngTotalRecordsFound Then intRecordDisplayedTo = lngTotalRecordsFound
End If
%>
Se você ainda não fechou todos os itens do seu casamento vale a pena dar uma olhada no B|K Busca - Guia de Casamento. No Guia de Casamento as noivas encontram dicas sobre casamento, vestido de noiva, traje de noivo, buffet, foto e video, lista de presente, cha de cozinha, locação de carros, lembrancinhas,
dia da noiva, e muito mais..