Ir para conteúdo

POWERED BY:

Arquivado

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

br1

select

Recommended Posts

Olá Pessoal estou com uma duvida a algum tempo tenho um campo de busca em meu site ele tem 3 opçõesquando uso essa sintexe abaixo ele obrigatoriamente tem que fazer a busca entre os 3 campos, ( categoria, tipo, local ) gostaria de saber como eu faço na minha busca para caso eu busque apenas por ( categoria, tipo ) ele anula o local e faz uma busca exata nesses dois campos. sql = "SELECT * FROM imoveis WHERE categoria = '"& var_categoria &"' and tipo = '"& var_tipo &"' and bairro = '"& var_local &"'"exe.Open sql, banco, , , adCmdTextMeu problema é que essa função está obrigando a fazer a busca com os tres campos .Aguardo RespostasSds,Bruno

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenho uma outra busca que você seleciona atraves de uma lista o que você deseja procurar.

Código:

ASP

[*]<%

[*]'Pesquisa

[*]Dim orderBy

[*]orderBy = request.querystring("orderby")

[*]

[*]dim SQL

[*]dim SearchFor

[*]dim SearchWhere

[*]SearchWhere = request("SearchWhere")

[*]SearchFor = request("SearchFor")

[*]dim SQL_SearchFor

[*]dim SQL_SearchWhere

[*]

[*]If (SearchWhere = "All") Then

[*] SQL_SearchWhere = "(Art_titulo LIKE ('%" & SearchFor & "%') OR Art_categoria LIKE ('%" & SearchFor & "%'))"

[*]Else

[*] SQL_SearchWhere = SearchWhere & " LIKE ('%" & SearchFor & "%')"

[*]End If

[*]

[*]If NOT (SearchFor = "") Then

[*] SQL_SearchFor = " WHERE " & SQL_SearchWhere

[*]Else

[*] SQL_SearchFor = ""

[*]End If

[*]

[*]If orderBy = "Art_titulo_Up" Then

[*] SQL_OrderBy = " ORDER BY Art_titulo DESC"

[*]ElseIf orderBy = "Art_titulo_Down" Then

[*] SQL_OrderBy = " ORDER BY Art_titulo"

[*]ElseIf orderBy = "Art_publica_Last_Up" Then

[*] SQL_OrderBy = " ORDER BY Art_publica_Last DESC"

[*]ElseIf orderBy = "Art_publica_Down" Then

[*] SQL_OrderBy = " ORDER BY Art_publica_Last"

[*]

[*]Else

[*] orderBy = "Art_categoria_Down"

[*] SQL_OrderBy = " ORDER BY Art_categoria"

[*]End If

[*]

[*]

[*]SQL = "SELECT * FROM Artigos" & SQL_SearchFor & SQL_OrderBy

[*]'Fim da Pesquisa

[*]%>

[*]

[*]

[*]<form action="artigos2.asp" Method="GET">

[*] <table width="450" border="0" align="center" cellpadding="0" cellspacing="0">

[*] <tr>

[*] <td width="90">Pesquisar por:</td><td width="140"> <input type="text" name="SearchFor" class="inputBox" value="<%=SearchFor%>" style="font-size: 8pt; font-family: Verdana; border: 1px solid #CCCCCC; color:#000000"></td>

[*] <td>em</td><td><select name="SearchWhere" class="inputBox" style="font-size: 8pt; font-family: Verdana; border: 1px solid #CCCCCC; color:#000000">

[*] <option value="All">Todos</option>

[*] <option value="Art_titulo">Título</option>

[*] <option value="Art_categoria">Categoria</option>

[*] </select></td><td><input type="submit" value="Enviar" class="inputSubmit" ></td>

[*] </tr>

[*] </table>

[*]</form>

[*]

 

Espero ter ajudado também...

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.