Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

israel brunini

Pesquisa retornar parte do conteudo

Recommended Posts

Olá, boa noite a todos. eu to tentando fazer o seguinte. Tenho um campo perguntas, e faço uma pesquisa nele, ele me retorna os registros, como faço pra ele retornar parte do texto do resultado, proximo a palavra chave, por ex

 

 

Palavra=memoria

 

Pergunta no banco:

 

Como corrigir um problema de memoria em um computador atlhon xp 1800+ placa mãe pcchips.

 

como retornar apenas o texto proximo a memoria ? sem retornar a pergunta inteira ???

 

 

muito obrigado. abraços.

Compartilhar este post


Link para o post
Compartilhar em outros sites

você quer pegar parte do texto e exibir??

 

se for isso utiliza ou o a função MID, ou LEFT o RIGHT, para cortar dos caracteres

Compartilhar este post


Link para o post
Compartilhar em outros sites

acho que isso vai funcionar pra você, basta criar um recordset rsPesquisa, e alterar os dados abaixo, o resultado será mais ou menos isso:

... bla bla bla bla sua palavra bla bla bla bla...

 

Espero que ajude...

 


	  <table width="100%">
		<% If Not rsPesquisa.EOF Or Not rsPesquisa.BOF Then %>
		<% 
While ((Repeat1__numRows <> 0) AND (NOT rsPesquisa.EOF)) 
	'codigo novo
	count = count + 1%>
		<%
	string1=request("keyword")

	tNoticia=tageater(rsPesquisa("MatConteudo"))
	EncontraPalavra=instr(tNoticia,lcase(trim(string1)))

	if EncontraPalavra=0 then
		wordd=UCase(Left(string1, 1)) & LCase(Right(string1, Len(string1) - 1))
		EncontraPalavra=instr(tNoticia,trim(wordd))
	end if

	if EncontraPalavra=0 then  'olha novamente
		news1=tageater(news1)
		news1=boldword(news1,trim(string1),"#FF9900")
		title1=boldword(rsPesquisa("MatTitulo"),trim(string1),"#FF9900")
	else
		if EncontraPalavra > 56 then
			PalavraEsquerda=left(tNoticia,EncontraPalavra-1)
			PalavraEsquerda=right(PalavraEsquerda,55)
		else
			PalavraEsquerda=""
		end if
		leftover=mid(tNoticia,EncontraPalavra+len(trim(string1)))

		if len(leftover)>55 then
			PalavraDireita=mid(tNoticia,EncontraPalavra+len(trim(string1)),55)
			news1="..."&PalavraEsquerda&trim(string1)&PalavraDireita&"..."
		else
			PalavraDireita=leftover
			news1="..."&PalavraEsquerda&trim(string1)&PalavraDireita&"..."
		end if

		news1=tageater(news1)
		news1=boldword(news1,trim(string1),"#FF9900")
		title1=boldword(rsPesquisa("MatTitulo"),trim(string1),"#FF9900")
	end if

	if news1="" then
		news1=boldword(rsPesquisa("MatConteudo"),trim(string1),"#FF9900")
	end if
%>
		<td align=left bgcolor=#EEEEEE> 
		  <p><font color=blue></font><b><font color=teal size=4>  </font></b> 
			[<%=rsPesquisa("MatData")%>]<a href="noticias_alterar.asp?ID=<%=rsPesquisa("MatCod")%>"> 
			<%=title1%></a>
			<!-- Por <b><font color=darkgreen> <%=rsPesquisa("matAutor")%></font></b-->
			<br>
			<%=news1%><a href="noticias_alterar.asp?ID=<%=rsPesquisa("MatCod")%>"><font size=2> 
			Mais</font></a>><br>
		  </p>
		</td>
		<tr> 
		<tr> 
		  <td background=""img/white.jpg""><img src=""img/white.jpg"" width=1 height=10></td>
		</tr>
		<%
PalavraEsquerda=""
news1=""
leftover=""
tNoticia=""
EncontraPalavra=""
wordd=""
PalavraDireita=""
%>
		<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsPesquisa.MoveNext()
Wend
%>

Function CleanUp(str)
	str = replace(str, chr(34), "")
	CleanUp=str
End Function

Function BoldWord(str, word, color)
   If word <> "" Then
	  pos = InStr(LCase(str), LCase(word))
	  If pos <> 0 Then
		 l = Left(str, pos - 1)
		 r = Right(str, Len(str) - pos - Len(word) + 1)
		 middle = Mid(str, pos, Len(word))
		 BoldWord = BoldWord & l & "<b><i>"
		 BoldWord = BoldWord & "<font color=""" & color & """>"
		 BoldWord = BoldWord & middle
		 BoldWord = BoldWord & "</font>"
		 BoldWord = BoldWord & "</i></b>" & r
	  Else
		 BoldWord = str
	  End If
   Else
	  BoldWord = str
   End If
End Function

function rf(stuff)
	rf=Request(stuff)
end function

Function TagEater(strPage)
'strips html code form a string
	Do
		pos = 1
		StartTag = InStr(pos,strPage,"<")
		If StartTag > 0 Then
			pos = StartTag
			If UCase(mid(strPage,StartTag,7)) = "<script" Then
				ScriptEnd = Instr(StartTag,UCase(strPage),"</SCRIPT>")
				strPage = Left(strPage,StartTag-1) & Right(strPage,Len(strPage)-ScriptEnd-8)
			Else
				EndTag = InStr(pos,strPage,">")
				If EndTag > 0 Then
					strPage = Left(strPage,StartTag-1) & Right(strPage,Len(strPage)-EndTag)
				Else
					strPage = Left(strPage,StartTag-1)
					Exit Do
				End If
			End If
		Else
			Exit Do
		End If
	Loop
	TagEater = strPage
End Function
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.