Ir ao conteúdo
  • Comunicados

    • Gabriel Torres

      Seja um moderador do Clube do Hardware!   12-02-2016

      Prezados membros do Clube do Hardware, Está aberto o processo de seleção de novos moderadores para diversos setores ou áreas do Clube do Hardware. Os requisitos são:   Pelo menos 500 posts e um ano de cadastro; Boa frequência de participação; Ser respeitoso, cordial e educado com os demais membros; Ter bom nível de português; Ter razoável conhecimento da área em que pretende atuar; Saber trabalhar em equipe (com os moderadores, coordenadores e administradores).   Os interessados deverão enviar uma mensagem privada para o usuário @Equipe Clube do Hardware com o título "Candidato a moderador". A mensagem deverá conter respostas às perguntas abaixo:   Qual o seu nome completo? Qual sua data de nascimento? Qual sua formação/profissão? Já atuou como moderador em algo outro fórum, se sim, qual? De forma sucinta, explique o porquê de querer ser moderador do fórum e conte-nos um pouco sobre você.   OBS: Não se trata de função remunerada. Todos que fazem parte do staff são voluntários.
    • DiF

      Poste seus códigos corretamente!   21-05-2016

      Prezados membros do Fórum do Clube do Hardware, O Fórum oferece um recurso chamado CODE, onde o ícone no painel do editor é  <>     O uso deste recurso é  imprescindível para uma melhor leitura, manter a organização, diferenciar de texto comum e principalmente evitar que os compiladores e IDEs acusem erro ao colar um código copiado daqui. Portanto convido-lhes para ler as instruções de como usar este recurso CODE neste tópico:  
Entre para seguir isso  
ersonsloan

Código para sistema de pesquisa

Recommended Posts

Pessoal eu estou montado um sistema de pesquisa estilo google so que está dando erro na hora de pesquisar:unsure: vocês poderiam verificar o codigo pra mim?

<html>

<head>

<title>Buscar na internet</title>

<script language="JavaScript">

.

function CheckForm () {

if (document.frmInterSaerch.search.value==""){

alert("Por favor insira uma palavra para realizar a busca");

document.frmInterSaerch.search.focus();

return false;

}

return true

}

// -->

</script>

</head>

<body bgcolor="#330099" text="#FFFFFF" link="#66CCFF" vlink="#66CCFF" alink="#FF0000">

<h1 align="center">Busca</h1>

<form method="get" name="frmInterSaerch" action="search.asp" onSubmit="return CheckForm();">

<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#333399">

<tr>

<td>   <a href="add_url_form.htm">Adicionar Url</a>      <a href="search.asp?mode=new">

Novas Urls</a>         <a href="search.asp?mode=random">Escolher Urls aleatoriamente</a></td>

</tr>

</table>

<table cellpadding="0" cellspacing="0" width="90%" align="center">

<tr>

<td height="61" width="231" align="right" rowspan="3"><img src="web_search.gif" width="45" height="49" align="absmiddle" alt="Busca na web">

</td>

<td height="61" width="21" align="right" rowspan="3"> </td>

<td class="arial" height="29" width="634" valign="bottom"> Página de busca:

</td>

</tr>

<tr>

<td class="normal" height="2" width="634">

<input type="TEXT" name="search" maxlength="50" size="35" value=<"=Request.QueryString("search") %>">

<input type="submit" value="Search >>" name="submit">

</td>

</tr>

<tr>

<td class="normal" height="29" width="634" valign="top"> Procurar por:

<input type="radio" name="mode" value="allwords" CHECKED>

Todas as palavras

<input type="radio" name="mode" value="anywords">

Qualquer uma das palavras </td>

</tr>

</table>

<%

'Dimension variables

Dim adoCon 'Database Connection Variable

Dim adoRec 'database Recordset Variable

Dim strAccessDB 'Holds the Access Database Name

Dim strSQL 'Database query sring

Dim intRecordPositionPageNum 'Holds the record position

Dim intRecordLoopCounter 'Loop counter for displaying the database records

Dim intTotalRecordsFound 'Holds the total number of records in the database

Dim intTotalNumPages 'holds the total number of pages in the database

Dim intLinkPageNum 'Holds the page number to be linked to

Dim strSearchKeywords 'Holds the keywords input by the user to be searched for

Dim strTitle 'Holds the URL Title

Dim strURL 'Holds the URL

Dim strDescription 'Holds the description of the URL

Dim sarySearchWord 'Holds the keywords for the URL

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 intRecordDisplayTo 'Holds the number of the search result that the page is displayed to

Dim intRandomRecordNumber 'Holds a random number used to display a random URL

'Declare constants

' Change the following line to the number of entries you wish to have on each page and miniumum word length

Const intRecordsPerPage = 10 'Change this number to the amount of entries to be displayed on each page

Const intMinuiumSesrchWordLength = 2 'Change this to the minimum word length to be searched on

'Error handler

On error resume next

'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 the search words to be searched

sarySearchWord = Split(Trim(Request.QueryString("search")), " ")

'Read in all the search words into one variable

strSearchKeywords = Trim(Request.QueryString("search"))

'Replace any less than or greater than signs with the HTML equivalent (stops people entering HTML tags)

strSearchKeywords = Replace(strSearchKeywords, "<", "<")

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 <= intMinuiumSesrchWordLength Then

blnSearchWordLenthOK = False

End If

Next

'Initalise the strSQL variable with an SQL statement to query the database

strSQL = "SELECT * FROM tblWebsites "

'If the user has selected to search any words then intalise the strSQL statement to search for any words in the database

If Request.QueryString("mode") = "anywords" The

'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) & "%'"

Nex

End If

'If the user has selected to search for all words then intalise the strSQL statement to search for entries containing all the search words

If Request.QueryString("mode") = "allwords" Then

'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

End If

'If the user has selected to see newly enetred URL's then order the search results by date decending

If Request.QueryString("mode") = "new" Then

'Order the search results by the date entered into the database decending

strSQL = strSQL & " ORDER By Date_Entered DESC"

'Else order the serch results by the number of click through hits decending

Else

'Order the search results by the number of click through hits decending (most popular sites first)

strSQL = strSQL & " ORDER By Hits DESC"

End If

'Initialise the strAccessDB variable with the name of the Access Database

strAccessDB = "search_engine"

'Create a connection odject

Set adoCon = Server.CreateObject("ADODB.Connection")

Set adoRec = Server.CreateObject("ADODB.Recordset")

'Open connection to the database driver

strCon = "DRIVER={Microsoft Access Driver (*.mdb)};"

'Open Connection to database

strCon = strCon & "DBQ=" & server.mappath(strAccessDB)

'Query the database with the strSQL statement

adoRec.Open strSQL, strCon, 3

'Set the number of records to display on each page by the constant set at the top of the script

adoRec.PageSize = intRecordsPerPage

'Get the page number record poistion to display from

adoRec.AbsolutePage = intRecordPositionPageNum

'Count the number of records found

intTotalRecordsFound = CInt(adoRec.RecordCount)

'Count the number of pages the search results will be displayed on calculated by the PageSize attribute set above

intTotalNumPages = CInt(adoRec.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 > intTotalRecordsFound Then intRecordDisplayedTo = intTotalRecordsFound

'Display the HTML table with the results status of the search or what type of search it is

Response.Write vbCrLf & " <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#333399"">"

Response.Write vbCrLf & " <tr>"

'Display that the URL is randomly generated

If Request.QueryString("mode") = "random" Then

Response.Write vbCrLf & " <td> Random URL.</td>"

'Display that we are showing a page of the latest URL's indexed

ElseIf Request.QueryString("mode") = "new" Then

Response.Write vbCrLf & " <td> The " & intRecordsPerPage & " latest URL's Indexed.</td>"

'Display that one of the words entered was to short

ElseIf blnSearchWordLenthOK = False Then

Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>.    One of the words searched is to short.</td>"

'Display that there where no matching records found

ElseIf adoRec.EOF Then

Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>.    Sorry, no results found.</td>"

'Else Search went OK so display how many records found

Else

Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>.    Displaying Results " & intRecordDisplayFrom & " - " & intRecordDisplayedTo & " of " & intTotalRecordsFound & ".</td>"

End If

'Close the HTML table with the search status

Response.Write vbCrLf & " </tr>"

Response.Write vbCrLf & " </table>"

'Display the various results

'HTML table to display the search results or an error if there are no results

Response.Write vbCrLf & " <br>" & vbCrLf

Response.Write vbCrLf & " <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"

Response.Write vbCrLf & " <tr>"

Response.Write vbCrLf & " <td>"

'Display a random URL

If Request.QueryString("mode") = "random" Then

'Randomise system timer

Randomize Timer

'Get a random number between 0 and highest number of records in database

intRandomRecordNumber = Int(RND * intTotalRecordsFound)

'Move to the choosen random record in the database

adoRec.Move intRandomRecordNumber

'Read in the values form the database

intSiteIDNo = CInt(adoRec("SiteIDNo"))

strTitle = adoRec("Title")

strURL = adoRec("URL")

strDescription = adoRec("Description")

intSiteHits = CInt(adoRec("Hits"))

'Display the randon URL details

Response.Write vbCrLf & " <a href=""get_url.asp?SiteID=" & intSiteIDNo & """ target=""_blank"">" & strTitle & "</a>"

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " " & strDescription

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " <font size=""1"" color=""#00CC99""><i>" & strURL & "  -  Hits " & intSiteHits & "</i></font>"

Response.Write vbCrLf & " <br><br>"

'Display error message if one of the words is to short

ElseIf blnSearchWordLenthOK = False And NOT Request.QueryString("mode") = "new" Then

'Write HTML displaying the error

Response.Write vbCrLf & " Your Search - <b>" & strSearchKeywords & "</b> - Contained a word with " & intMinuiumSesrchWordLength & " letters or less, this is to short to search."

Response.Write vbCrLf & " <br><br>"

Response.Write vbCrLf & " Suggestions:"

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " <ul><li>Try longer keywords.<li>Make sure all words are spelled correctly.<li>Try different keywords.<li>Try more general keywords.</ul>"

'If no search results found then show an error message

ElseIf adoRec.EOF Then

'Write HTML displaying the error

Response.Write vbCrLf & " Your Search - <b>" & strSearchKeywords & "</b> - did not match any documents."

Response.Write vbCrLf & " <br><br>"

Response.Write vbCrLf & " Suggestions:"

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " <ul><li>Make sure all words are spelled correctly.<li>Try different keywords.<li>Try more general keywords.<li>Try fewer keywords.</ul>"

Else

'For....Next Loop to display the results from the database

For intRecordLoopCounter = 1 to intRecordsPerPage

'If there are no records left to display then exit loop

If adoRec.EOF Then Exit For

'Read in the values form the database

intSiteIDNo = CInt(adoRec("SiteIDNo"))

strTitle = adoRec("Title")

strURL = adoRec("URL")

strDescription = adoRec("Description")

intSiteHits = CInt(adoRec("Hits"))

'Display the details of the URLs found

Response.Write vbCrLf & " <a href=""get_url.asp?SiteID=" & intSiteIDNo & """ target=""_blank"">" & strTitle & "</a>"

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " " & strDescription

Response.Write vbCrLf & " <br>"

Response.Write vbCrLf & " <font size=""1"" color=""#00CC99""><i>" & strURL & "  -  Hits " & intSiteHits & "</i></font>"

Response.Write vbCrLf & " <br><br>"

'Move to the next record in the database

adoRec.MoveNext

'Loop back round

Next

End If

'Close the HTML table displaying the results

Response.Write vbCrLf & " </td>"

Response.Write vbCrLf & " </tr>"

Response.Write vbCrLf & " </table>"

'Display an HTML table with links to the other search results if not showing latest 10, a random URL, or not under min word length

If NOT Request.QueryString("mode") = "new" And NOT Request.QueryString("mode") = "random" And blnSearchWordLenthOK = True Then

'Display an HTML table with links to the other search results

Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"

Response.Write vbCrLf & " <tr>"

Response.Write vbCrLf & " <td>"

Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"

Response.Write vbCrLf & " <tr>"

Response.Write vbCrLf & " <td width=""50%"" align=""center"">"

'If there are more pages to display then add a title to the other pages

If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then

Response.Write vbCrLf & " Results Page:  "

End If

'If the page number is higher than page 1 then display a back link

If intRecordPositionPageNum > 1 Then

Response.Write vbCrLf & " <a href=""search.asp?PagePosition=" & intRecordPositionPageNum - 1 & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") &""" target=""_self""><< Prev</a>  "

End If

'If there are more pages to display then display links to all the search results pages

If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then

'Loop to diplay a hyper-link to each page in the search results

For intLinkPageNum = 1 to intTotalNumPages

'If the page to be linked to is the page displayed then don't make it a hyper-link

If intLinkPageNum = intRecordPositionPageNum Then

Response.Write vbCrLf & " " & intLinkPageNum

Else

Response.Write vbCrLf & "  <a href=""search.asp?PagePosition=" & intLinkPageNum & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">" & intLinkPageNum & "</a>  "

End If

Next

End If

'If it is Not the End of the search results than display a next link

If NOT adoRec.EOF then

Response.Write vbCrLf & "  <a href=""search.asp?PagePosition=" & intRecordPositionPageNum + 1 & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">Next >></a>"

End If

'Finsh HTML the table

Response.Write vbCrLf & " </td>"

Response.Write vbCrLf & " </tr>"

Response.Write vbCrLf & " </table>"

Response.Write vbCrLf & " </td>"

Response.Write vbCrLf & " </tr>"

Response.Write vbCrLf & " </table>"

Response.Write vbCrLf & " <br>"

End If

'Close Server Objects

Set adoCon = Nothing

Set adoCmd = Nothing

%>

</form>

<table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#333399" align="center">

<tr>

<td width="47%">  <a href="add_url_form.htm">Adicionar URL</a>      <a href="search.asp?mode=new">

Novas Urls</a>         <a href="search.asp?mode=random">Procurar aleatoriamente </a></td>

</tr>

</table>

</body>

</html>

Quando eu clico em pesquisar aparece a texto em vermelho dentro do text box, e ajudem please muito obrigo fiquem com Deus!!! Editado por Libra
Título do tópico e fonte fora das regras.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Entre para seguir isso  





Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas publicações sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×