Ir para conteúdo

Arquivado

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

cintiadel

Select com Filtro

Recommended Posts

e existe algum registro que satisfaça todas estas condições?

Compartilhar este post


Link para o post
Compartilhar em outros sites

aparentemente nao existe mais erros

 

como esta tentando exibir os dados buscados?

Compartilhar este post


Link para o post
Compartilhar em outros sites

so mai sum detalhe

 

LOCAL é palavra reservada é bom colocar entre colchetes

Compartilhar este post


Link para o post
Compartilhar em outros sites

e existe algum registro que satisfaça todas estas condições?

mais de um inclusive

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GuiaD Restaurantes, Hotéis & Bares</title>
<link href="css/link.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana;
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style2 {
	color: #FFFFFF;
	font-size: 16px;
	font-weight: bold;
}
.style3 {
	font-size: 9px;
	color: #FFFFFF;
}
.style4 {
	font-size: 14px;
	color: #3B3763;
}
.style6 {font-size: 8.5px}
.style7 {color: #FFFFFF}
.style8 {color: #FFFFFF; font-size: 10px; }
.style10 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>
<!--#include file="Conexao.inc" -->

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"

if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if

if request("escolha") = "mais" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("MaisVotadosLista.asp")
end if

if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
db.execute myselLoc1
%>
<body>
<table width="681" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
	<td height="100" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
		<td width="6" height="100" valign="top"><img src="img/img/latEsqBannerCima.jpg" width="6" height="100" /></td>
		<td width="274" valign="top" bgcolor="#312D60"><img src="img/img/logo.jpg" width="274" height="100" /></td>
		<td width="394" valign="top" bgcolor="#312D60"><!--DWLayoutEmptyCell--> </td>
		<td width="6" valign="top"><img src="img/img/latDirBannerCima.jpg" width="6" height="100" /></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td height="2" colspan="6" valign="top"><img src="img/img/linha1.jpg" width="13" height="2" /></td>
  </tr>
  <tr>
	<td width="150" height="181" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
		<td width="150" height="4" valign="top"><img src="img/img/menuCima.jpg" width="150" height="4" /></td>
	  </tr>
	  <tr>
		<td height="174" valign="middle" bgcolor="#F5781C"><table width="145" border="0" align="center" cellpadding="1" cellspacing="1">
		  <tr>
			<td><a href="Index.asp">Home</a></td>
		  </tr>
		  <tr>
			<td><a href="BuscaAvan.asp">Busca Avançada </a></td>
		  </tr>
		  <tr>
			<td><a href="Participe.asp">Participe e Concorra </a></td>
		  </tr>
		  <tr>
			<td><a href="MaisVotados.asp">Os Mais Votados </a></td>
		  </tr>
		  <tr>
			<td><a href="Compre.asp">Compre o GuiaD </a></td>
		  </tr>
		  <tr>
			<td><a href="Sobre.asp">Sobre o GuiaD </a></td>
		  </tr>
		  <tr>
			<td><a href="Personalizado.asp">GuiaD Personalizado</a></td>
		  </tr>
		  <tr>
			<td><a href="Fale.asp">Fale Conosco</a></td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td height="3" valign="top"><img src="img/img/menuBaixo.jpg" width="150" height="3" /></td>
	  </tr>
	</table></td>
	<td width="1" rowspan="2" valign="top"><img src="img/img/linha2.jpg" width="1" height="11" /></td>
	<td width="175" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
		<td width="175" height="4" valign="top"><img src="img/img/votadosCima.jpg" width="175" height="4" /></td>
	  </tr>
	  <tr>
		<td height="403" valign="middle" bgcolor="#A12820"><form id="form2" name="form2" method="post" action="">
		</form></td>
	  </tr>
	  <tr>
		<td height="4" valign="top"><img src="img/img/votadosBaixo.jpg" width="175" height="4" /></td>
	  </tr>
	</table></td>
	<td width="1" rowspan="2" valign="top"><img src="img/img/linha2.jpg" width="1" height="11" /></td>
	<td width="351" rowspan="2" valign="top"><table width="75%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
		<td width="752" height="4" valign="top"><img src="img/img/maisCima.jpg" width="351" height="4" /></td>
	  </tr>
	  <tr>
		<td height="403" align="center" valign="middle" bgcolor="#848DAC"><table width="50%" border="0" align="left" cellpadding="2" cellspacing="2">
		   <%
											  rsLoc.open myselLoc1, db
											  while not rsLoc.eof
										  %>
		  <tr>
		 

			<td width="358">
							<%=rsLoc.fields("nomeLoc")%>
				
			</td>
			<%
											  rsLoc.movenext
											  wend 
											  rsLoc.close
										  %>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td height="4" valign="top"><img src="img/img/maisBaixo.jpg" width="351" height="4" /></td>
	  </tr>
	</table></td>
	<td width="3"> </td>
  </tr>
  <tr>
	<td height="230" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
		<td width="150" height="2" valign="top"><img src="img/img/linha1.jpg" width="13" height="2" /></td>
	  </tr>
	  <tr>
		<td height="3" valign="top"><img src="img/img/buscaCima.jpg" width="150" height="3" /></td>
	  </tr>
	  <tr>
		<td height="222" valign="middle" bgcolor="#7F7047"><form id="busca" name="busca" method="post" action="BuscaRes.asp">
		  <table width="145" border="0" align="center" cellpadding="1" cellspacing="1">
			<tr>
			  <td colspan="2"><span class="style2">Busca D</span></td>
			</tr>
			<tr>
			  <td colspan="2"><select name="nomeLoc" id="nomeLoc">
				<option selected="selected" value="">Nome</option>
				<%
											  rsLoc.open myselLoc, db
											  while not rsLoc.eof
										  %>
				<option value="<%=rsLoc.fields("nomeLoc")%>"><%=rsLoc.fields("nomeLoc")%></option>
				<%
											  rsLoc.movenext
											  wend 
											  rsLoc.close
										  %>
			  </select></td>
			</tr>
			<tr>
			  <td colspan="2"><select name="tipoLoc" id="tipoLoc">
				<option selected="selected" value="">Tipo</option>
				<option value="Bar">Bar</option>
				<option value="Hotel">Hotel</option>
				<option value="Restaurante">Restaurante</option>
			  </select></td>
			</tr>
			<tr>
			  <td colspan="2"><select name="catLoc" id="catLoc">
				<option selected="selected" value="">Categoria</option>
				<%
										  rsCat.open myselCat, db
										  while not rsCat.eof
									  %>
				<option value="<%=rsCat.fields("nomeCat")%>"><%=rsCat.fields("nomeCat")%></option>
				<%
										  rsCat.movenext
										  wend 
										  rsCat.close
									  %>
			  </select></td>
			</tr>
			<tr>
			  <td colspan="2"><select name="estLoc" id="estLoc">
				<option>Estado</option>
				<%
						  rsEst.open myselEst, db
						  while not rsEst.eof
					  %>
				<option value="<%=rsEst.fields("siglaEst")%>"><%=rsEst.fields("siglaEst")%></option>
				<%
						  rsEst.movenext
						  wend 
						  rsEst.close
					 %>
			  </select></td>
			</tr>
			<tr>
			  <td colspan="2"><input name="cidLoc" type="text" id="cidLoc" value="Cidade" /></td>
			</tr>
			<tr>
			  <td colspan="2"><input name="bairLoc" type="text" id="bairLoc" value="Bairro" /></td>
			</tr>
			<tr>
			  <td width="94"><span class="style3"><a href="BuscaAvan.asp">Busca Avançada</a></span> </td>
			  <td width="44" align="right"><input name="btnBuscar2" type="image" id="btnBuscar2" src="img/img/btnBuscar.jpg" /></td>
			</tr>
		  </table>
		</form></td>
	  </tr>
	  <tr>
		<td height="3" valign="top"><img src="img/img/buscaBaixo.jpg" width="150" height="3" /></td>
	  </tr>
	</table></td>
	<td> </td>
  </tr>
</table>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estranho, sempre vai ter request("escolha") = "mais" ou request("escolha") = "cozinha"?

Se sim, tem que checar o código das páginas MaisVotadosLista.asp e CatCozinhas.asp, já que você faz um Response.Redirect.

Outra coisa, não entendi o porque do db.execute myselLoc1 antes do <body>.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estranho, sempre vai ter request("escolha") = "mais" ou request("escolha") = "cozinha"?

Se sim, tem que checar o código das páginas MaisVotadosLista.asp e CatCozinhas.asp, já que você faz um Response.Redirect.

Outra coisa, não entendi o porque do db.execute myselLoc1 antes do <body>.

 

sim porque a pessoa

 

Estranho, sempre vai ter request("escolha") = "mais" ou request("escolha") = "cozinha"?

Se sim, tem que checar o código das páginas MaisVotadosLista.asp e CatCozinhas.asp, já que você faz um Response.Redirect.

Outra coisa, não entendi o porque do db.execute myselLoc1 antes do <body>.

 

sim porque a pessoa vai escolher se ela que ver as 5 melhores de cada categoria ou os 50 mais votados.

o q preciso checar nessas páginas?

eu costumo colocar pra executar o select, nao precisa?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tem que checar o código delas, se está fazendo o select corretamente.

maisVotadosLista.asp está o código que eu postei:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
if request("escolha") = "mais" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("MaisVotadosLista.asp")
end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
db.execute myselLoc1
%>

e na catCozinhas.asp

<%

myselLoc= "select * from Local"
myselCat= "select idCat, nomeCat from Categoria"
myselEst= "select idEst, siglaEst from Estado"

%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se esta é a MaisVotadosLista.asp, aqui não precisa redirecionar:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
if request("escolha") = "mais" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
'response.Redirect("MaisVotadosLista.asp") Não precisa redirecionar
end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
'db.execute myselLoc1 Não sei o porque desta linha
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se esta é a MaisVotadosLista.asp, aqui não precisa redirecionar:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
if request("escolha") = "mais" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
'response.Redirect("MaisVotadosLista.asp") Não precisa redirecionar
end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
'db.execute myselLoc1 Não sei o porque desta linha
%>

tá dando erro:

Microsoft OLE DB Provider for SQL Server erro '80040e14'

Invalid column name 'escolha'.

/guiad/asp/MaisVotadosLista.asp, line 64

eu troquei onde esta request("escolha") para request("mais") e request("cozinha")

que sao os valores do radio mas nao funcionou deu esse erro

Compartilhar este post


Link para o post
Compartilhar em outros sites

existe esta coluna no db? escolha?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenta assim:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
'Não é necessário, pois se entrar no próximo If, vai redirecionar para outra página
'if request("escolha") = "mais" then
'myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
'response.Redirect("MaisVotadosLista.asp") Não precisa redirecionar
'end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
'db.execute myselLoc1 Não sei o porque desta linha
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

existe esta coluna no db? escolha?

escolha foi o nome que eu dei para o radio, mas essa opcao é so pra ele direcionar a página.

Compartilhar este post


Link para o post
Compartilhar em outros sites

e quais sao oc nomes de campo para cada uma opção da escolha

 

é este nome que voce precisa colocar ali

Compartilhar este post


Link para o post
Compartilhar em outros sites

e quais sao oc nomes de campo para cada uma opção da escolha

 

é este nome que voce precisa colocar ali

os dois chamam escolha e o value de um é 'mais' e do outro 'cozinha'

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenta assim:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
'Não é necessário, pois se entrar no próximo If, vai redirecionar para outra página
'if request("escolha") = "mais" then
'myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
'response.Redirect("MaisVotadosLista.asp") Não precisa redirecionar
'end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
'db.execute myselLoc1 Não sei o porque desta linha
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenta assim:

<%
myselLoc1 = "select * from Local where posicaoVotado<=50"
if request("cidade") <> "" then
myselLoc1 = myselLoc1 & " and cidLoc='" & request("cidade") & "'"
end if
'Não é necessário, pois se entrar no próximo If, vai redirecionar para outra página
'if request("escolha") = "mais" then
'myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
'response.Redirect("MaisVotadosLista.asp") Não precisa redirecionar
'end if
if request("escolha") = "cozinha" then
myselLoc1 = myselLoc1 & " and escolha='" & request("escolha") & "'"
'Response.Write myselLoc1
'Response.End
response.Redirect("CatCozinhas.asp")
end if
'db.execute myselLoc1 Não sei o porque desta linha
%>

agora sim está funcionando, mais uma vez muitoooooooooo mas muitoooo obrigada...

só o da cidade ainda nao ta filtrando pelo parametro da cidade, só ta pegando as 5 melhores da categoria

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.