• 0
Sign in to follow this  
aureo_2006

Busca Em Multiplos Campos Com Criterios Diferentes

Question

Eu estou precisando construir uma página de busca em uma tabela cm mais de um criterio. Tipo: na página de busca ter como opção buscar carro, modelo, ano e valor que estão em campos da tabela com estes mesmos nomes. alguém conhece um tutorial que oriente como fazer isso? Ou saberia dar uma dica? Vi muitos tutorias que orientam a fazer busca em um um campo ou então em vários campos mas com um mesmo critério...Tambem não achei nenhuma extensão que ajudasse a fazer esta pesquisa em multiplos campos...pesquisas simples tudo bem, mas em multiplos campos com multiplos critérios não achei nenhuma extensão.

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

olha só já chego a fazer com um criterio só?

faça depois copie a página que fez para realizar a busca aqui ai lhe mostro onde trocar os campos para duas busca depois se copia ai e colocar no DW ai abre ele e veja onde esta o segundo campo e tenta fazer

o que me diz?

Share this post


Link to post
Share on other sites
  • 0
Guest Luiz Sergio

Eu também preciso criar um um sistema que busque em mais de uma opção de escolha, tipo o codigo abaixo:

FORMULARIO DE ENVIO: busca_avancada.asp

<form name="form1" action="result_b_avancada.asp" method=get>

<table align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="456"> <p><font face="Tahoma" color="blue"><span style="font-size:10pt;">Tipo do imóvel:<br></span></font> <font face="Tahoma" color="blue"><span style="font-size:10pt;"><select name="palavra" style="width=450">

<option selected value=" ">Selecione um tipo</option>

<option value="Casa Residencial">Casa Residencial</option>

<option value="Terrenos">Terrenos</option>

<option value="Apartamentos">Apartamentos</option>

<option value="Sobrados">Sobrados</option>

</select></span></font></p><p><font face="Tahoma" color="blue"><span style="font-size:10pt;">Bairro:<br><select name="palavra2" style="width=450">

<option selected value=" ">Selecione</option>

<%

%>

<option value="Jundiaí">Jundiaí</option>

<%%>

<option value="Maracanã">Maracanã</option>

<option value="Santa Maria">Santa Maria</option>

<option value="Vila Góis">Vila Góis</option>

<option value="Centro">Centro</option>

</select></span></font></p>

<p><font face="Tahoma" color="blue"><span style="font-size:10pt;">Quartos:<br><select name="palavra3" style="width=450" size="1">

<option selected value=" ">Selecione</option>

<option value="1">1 Quarto</option>

<option value="2">2 Quartos</option>

<option value="3">3 Quartos</option>

<option value="4">4 Quartos</option>

<option value="5">5 Quartos</option>

</select></span></font></p>

</td>

</tr>

</table>

<p align="center">

<input type="submit"></p>

</form>

PAGINA DE RESULTADOS: result_b_avancada.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include file="Connections/dados.asp" -->

<%

Dim ver_imoveis__MMColParam3

ver_imoveis__MMColParam3 = "1"

If (Request.QueryString("palavra3") <> "") Then

ver_imoveis__MMColParam3 = Request.QueryString("palavra3")

End If

%>

<%

Dim ver_imoveis__MMColParam

ver_imoveis__MMColParam = "1"

If (Request.QueryString("palavra") <> "") Then

ver_imoveis__MMColParam = Request.QueryString("palavra")

End If

%>

<%

Dim ver_imoveis__MMColParam2

ver_imoveis__MMColParam2 = "1"

If (Request.QueryString("palavra2") <> "") Then

ver_imoveis__MMColParam2 = Request.QueryString("palavra2")

End If

%>

<%

Dim ver_imoveis

Dim ver_imoveis_numRows

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

ver_imoveis.ActiveConnection = MM_dados_STRING

ver_imoveis.Source = "SELECT * FROM imoveis WHERE para_a_busca LIKE '%" + Replace(ver_imoveis__MMColParam, "'", "''") + "%' & '%" + Replace(ver_imoveis__MMColParam2, "'", "''") + "%' & '%" + Replace(ver_imoveis__MMColParam3, "'", "''") + "%' ORDER BY preço ASC"

ver_imoveis.CursorType = 0

ver_imoveis.CursorLocation = 2

ver_imoveis.LockType = 1

ver_imoveis.Open()

ver_imoveis_numRows = 0

%>

<%

Dim Repeat1__numRows

Dim Repeat1__index

Repeat1__numRows = 10

Repeat1__index = 0

ver_imoveis_numRows = ver_imoveis_numRows + Repeat1__numRows

%>

<%

' *** Move To Record and Go To Record: declare variables

Dim MM_rs

Dim MM_rsCount

Dim MM_size

Dim MM_uniqueCol

Dim MM_offset

Dim MM_atTotal

Dim MM_paramIsDefined

Dim MM_param

Dim MM_index

Set MM_rs = ver_imoveis

MM_rsCount = ver_imoveis_total

MM_size = ver_imoveis_numRows

MM_uniqueCol = ""

MM_paramName = ""

MM_offset = 0

MM_atTotal = false

MM_paramIsDefined = false

If (MM_paramName <> "") Then

MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")

End If

%>

<%

' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

' use index parameter if defined, otherwise use offset parameter

MM_param = Request.QueryString("index")

If (MM_param = "") Then

MM_param = Request.QueryString("offset")

End If

If (MM_param <> "") Then

MM_offset = Int(MM_param)

End If

' if we have a record count, check if we are past the end of the recordset

If (MM_rsCount <> -1) Then

If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last

If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region

MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)

Else

MM_offset = MM_rsCount - MM_size

End If

End If

End If

' move the cursor to the selected record

MM_index = 0

While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))

MM_rs.MoveNext

MM_index = MM_index + 1

Wend

If (MM_rs.EOF) Then

MM_offset = MM_index ' set MM_offset to the last possible record

End If

End If

%>

<%

' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

' walk to the end of the display range for this page

MM_index = MM_offset

While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))

MM_rs.MoveNext

MM_index = MM_index + 1

Wend

' if we walked off the end of the recordset, set MM_rsCount and MM_size

If (MM_rs.EOF) Then

MM_rsCount = MM_index

If (MM_size < 0 Or MM_size > MM_rsCount) Then

MM_size = MM_rsCount

End If

End If

' if we walked off the end, set the offset based on page size

If (MM_rs.EOF And Not MM_paramIsDefined) Then

If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then

If ((MM_rsCount Mod MM_size) > 0) Then

MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)

Else

MM_offset = MM_rsCount - MM_size

End If

End If

End If

' reset the cursor to the beginning

If (MM_rs.CursorType > 0) Then

MM_rs.MoveFirst

Else

MM_rs.Requery

End If

' move the cursor to the selected record

MM_index = 0

While (Not MM_rs.EOF And MM_index < MM_offset)

MM_rs.MoveNext

MM_index = MM_index + 1

Wend

End If

%>

<%

' *** Move To Record: update recordset stats

' set the first and last displayed record

ver_imoveis_first = MM_offset + 1

ver_imoveis_last = MM_offset + MM_size

If (MM_rsCount <> -1) Then

If (ver_imoveis_first > MM_rsCount) Then

ver_imoveis_first = MM_rsCount

End If

If (ver_imoveis_last > MM_rsCount) Then

ver_imoveis_last = MM_rsCount

End If

End If

' set the boolean used by hide region to check if we are on the last record

MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)

%>

<%

' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove

Dim MM_moveParam

Dim MM_moveFirst

Dim MM_moveLast

Dim MM_moveNext

Dim MM_movePrev

Dim MM_urlStr

Dim MM_paramList

Dim MM_paramIndex

Dim MM_nextParam

MM_keepMove = MM_keepBoth

MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters

If (MM_size > 1) Then

MM_moveParam = "offset"

If (MM_keepMove <> "") Then

MM_paramList = Split(MM_keepMove, "&")

MM_keepMove = ""

For MM_paramIndex = 0 To UBound(MM_paramList)

MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)

If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then

MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)

End If

Next

If (MM_keepMove <> "") Then

MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)

End If

End If

End If

' set the strings for the move to links

If (MM_keepMove <> "") Then

MM_keepMove = MM_keepMove & "&"

End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"

MM_moveLast = MM_urlStr & "-1"

MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)

If (MM_offset - MM_size < 0) Then

MM_movePrev = MM_urlStr & "0"

Else

MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)

End If

%>

<HTML>

<HEAD>

<TITLE>WCARVALHO IMÓVEIS - </TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<meta name="generator" content="Namo WebEditor v5.0(Trial)">

</HEAD>

<BODY BGCOLOR="#ffffff" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

<table cellpadding="0" cellspacing="0" width="507">

<%

While ((Repeat1__numRows <> 0) AND (NOT ver_imoveis.EOF))

%>

<tr>

<td align="default" width="9%" valign="top">

<p align="center">

</p></td>

<td align="default" width="463" valign="top">

<p><font face="Tahoma"><span style="font-size:9pt;"><%=(ver_imoveis.Fields.Item("bairro").Value)%>

-<b><%=(ver_imoveis.Fields.Item("preço").Value)%>.</b></span></font>

</td>

</tr>

<tr>

<td align="default" width="507" colspan="2">

<p><img src="linha_cel.jpg" width="503" height="3" border="0"></p>

</td>

</tr>

<%

Repeat1__index=Repeat1__index+1

Repeat1__numRows=Repeat1__numRows-1

ver_imoveis.MoveNext()

Wend

%>

</table>

</BODY>

</HTML>

<%

ver_imoveis.Close()

Set ver_imoveis = Nothing

%>

QUANDO SELECIONO O "casa residencial" aparece somente uma sendo que são mais de 10 e se selecionar outro campo, não aparece nada..

MNE AJUDE POR FAVOR.

Share this post


Link to post
Share on other sites
  • 0
Guest Luiz Sergio
Você fez um while na pagina de resultados?

Onde e como deveria ser este while?

Entendo mais ainda não muito!.. pode me ajudar com o script informado acima?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this