Ir para conteúdo

POWERED BY:

Arquivado

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

kania

Erro com loop

Recommended Posts

Onde esta o erro neste loop?

 

 

<%
est=request.QueryString("es")
es=est
if es = "AC" then
es = "Acre"
end if   
if es = "AL"  then
es = "Alagoas"
end if	  
if es = "AP"  then
es = "Amapá"
end if	  
if es = "AM"  then
es = "Amazonas"
end if	  
if es = "BA"  then
es = "Bahia"
end if	  
if es = "CE"  then
es = "Ceará"
end if	  
if es = "DF"  then
es = "Distrito Federal"
end if	  
if es = "ES"  then
es = "Espírito Santo"
end if	  
if es = "GO" then
es = "Goiás"
end if	  
if es = "MA"  then
es = "Maranhão"
end if	 
if es = "MT"  then
es = "Mato Grosso"
end if	 
if es = "MS"  then
es = "Mato Grosso do Sul"
end if	 
if es = "MG"  then
es = "Minas Gerais"
end if	  
if es = "PA"  then
es = "Pará"
end if	  
if es = "PB"  then
es = "Paraíba"
end if	  
if es = "PR"  then
es = "Paraná"
end if	  
if es = "PE"  then
es = "Pernambuco"
end if	  
if es = "PI"  then
es = "Piauí"
end if	 
if es = "RJ"  then
es = "Rio de Janeiro"
end if	 
if es = "RN"  then
es = "Rio Grande do Norte"
end if	 
if es = "RS"  then
es = "Rio Grande do Sul"
end if	  
if es = "RO"  then
es = "Rondônia"
end if	  
if es = "RR"  then
es = "Roraima"
end if	  
if es = "SC"  then
es = "Santa Catarina"
end if	 
if es = "SP"  then
es = "São Paulo"
end if	  
if es = "SE"  then
es = "Sergipe"
end if	  
if es = "TO"  then
es = "Tocantins"
end if	 


Set RS = Server.CreateObject("adodb.recordset")
SQL = "select * from reuniao where estado='"&est&"'"
RS.Open SQL,Conn,3,3
if rs.eof then%>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td>
	  <div align="center">
		<table id="Table_01" width="250" height="250" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td width="250" height="116" background="imagens/fundo_estado.gif"><table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
			  <td><div align="center"><span class="estiloNomeTopo">Nenhum evento cadastrado para o estado</span> <span class="TextoTitulo"><%=es%></span></div></td>
			</tr>
		  </table></td>
	  </tr>
		  <tr>
			<td>
			  <img src="imagens/fundo_estado_02.gif" width="250" height="134" alt=""></td>
	  </tr>
		</table>
	</div></td>
  </tr>
</table>

<%
else
total = rs.recordcount
   x = 0
   do while x < total
   
estado = Rs("estado")
if estado = "AC" then
estado = "Acre"
end if   
if estado = "AL"  then
estado = "Alagoas"
end if	  
if estado = "AP"  then
estado = "Amapá"
end if	  
if estado = "AM"  then
estado = "Amazonas"
end if	  
if estado = "BA"  then
estado = "Bahia"
end if	  
if estado = "CE"  then
estado = "Ceará"
end if	  
if estado = "DF"  then
estado = "Distrito Federal"
end if	  
if estado = "ES"  then
estado = "Espírito Santo"
end if	  
if estado = "GO" then
estado = "Goiás"
end if	  
if estado = "MA"  then
estado = "Maranhão"
end if	 
if estado = "MT"  then
estado = "Mato Grosso"
end if	 
if estado = "MS"  then
estado = "Mato Grosso do Sul"
end if	 
if estado = "MG"  then
estado = "Minas Gerais"
end if	  
if estado = "PA"  then
estado = "Pará"
end if	  
if estado = "PB"  then
estado = "Paraíba"
end if	  
if estado = "PR"  then
estado = "Paraná"
end if	  
if estado = "PE"  then
estado = "Pernambuco"
end if	  
if estado = "PI"  then
estado = "Piauí"
end if	 
if estado = "RJ"  then
estado = "Rio de Janeiro"
end if	 
if estado = "RN"  then
estado = "Rio Grande do Norte"
end if	 
if estado = "RS"  then
estado = "Rio Grande do Sul"
end if	  
if estado = "RO"  then
estado = "Rondônia"
end if	  
if estado = "RR"  then
estado = "Roraima"
end if	  
if estado = "SC"  then
estado = "Santa Catarina"
end if	 
if estado = "SP"  then
estado = "São Paulo"
end if	  
if estado = "SE"  then
estado = "Sergipe"
end if	  
if estado = "TO"  then
estado = "Tocantins"
end if	 

%>
<table width="390" border="0" cellpadding="0" cellspacing="0" bgcolor="#0066FF">
  <tr>
	<td>
	
	<table width="390" border="0" cellpadding="3" cellspacing="3">
  
  <tr>
	<td height="35" colspan="4" class="TabelaReunioes"><div align="center" class="TextoTitulo"><%=Rs("tipo")%> </div></td>
	</tr>
  <tr>
	<td width="70" height="25" class="TabelaReunioes"><strong>Data:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("data")%> - <%=Rs("dia_semana")%> às <%=Rs("hora")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Local:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("local")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Endereço:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("endereco")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Cidade:</strong></td>
	<td width="142" height="25" class="TabelaReunioes"><%=Rs("cidade")%></td>
	<td width="48" height="25" class="TabelaReunioes">Estado:</td>
	<td width="130" height="25" class="TabelaReunioes"><%=estado%></td>
  </tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Contato:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("contato")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Telefone</strong>:</td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("telefone")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Custo:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes">R$ <%=Rs("custo")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Obs:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("obs")%></td>
	</tr>
</table></td>
  </tr>
</table>
	
<%
  x = x + 1
  rs.movenext
  loop
  end if
  rs.close

%>

Ao clicar no link para trazer o estado, mesmo tendo informações no BD MySQL ele traz a tela em branco, na questão de estar em branco a informação aparece corretamente, o probelma é somente quando o BD esta com dados.

Mandei imprimir na tela a informação para ver se tinha erro no select e deu o seguinte:

 

1 - Se o response estiver antes do loop ele imprime certinho

2 - Se o response estiver depois do loop da como pagina em branco.

 

Como fazer o loop no MySQL?

Compartilhar este post


Link para o post
Compartilhar em outros sites

veja agora:

 

concertei tudo!!!

 

<%
Select Case (CStr(Request.QueryString("es")))
	Case("AC") : str_ESTADO = "Acre"
	Case("AL") : str_ESTADO = "Alagoas"
	Case("AP") : str_ESTADO = "Amapá"
	Case("AM") : str_ESTADO = "Amazonas"
	Case("BA") : str_ESTADO = "Bahia"
	Case("CE") : str_ESTADO = "Ceará"
	Case("DF") : str_ESTADO = "Distrito Federal"
	Case("ES") : str_ESTADO = "Espírito Santo"
	Case("GO") : str_ESTADO = "Goiás"
	Case("MA") : str_ESTADO = "Maranhão"
	Case("MT") : str_ESTADO = "Mato Grosso"
	Case("MS") : str_ESTADO = "Mato Grosso do Sul"
	Case("MG") : str_ESTADO = "Minas Gerais"
	Case("PA") : str_ESTADO = "Pará"
	Case("PB") : str_ESTADO = "Paraíba"
	Case("PR") : str_ESTADO = "Paraná"
	Case("PE") : str_ESTADO = "Pernambuco"
	Case("PI") : str_ESTADO = "Piauí"
	Case("RJ") : str_ESTADO = "Rio de Janeiro"
	Case("RN") : str_ESTADO = "Rio Grande do Norte"
	Case("RS") : str_ESTADO = "Rio Grande do Sul"
	Case("RO") : str_ESTADO = "Rondônia"
	Case("RR") : str_ESTADO = "Roraima"
	Case("SC") : str_ESTADO = "Santa Catarina"
	Case("SP") : str_ESTADO = "São Paulo"
	Case("SE") : str_ESTADO = "Sergipe"
	Case("TO") : str_ESTADO = "Tocantins"
End Select

Dim RS
Rs = Conn.Execute("select * from reuniao where estado = '"&CStr(Request.QueryString("es"))&"'")
if rs.eof then
%>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td>
		<table id="Table_01" width="250" height="250" border="0" cellpadding="0" cellspacing="0" align="center">
		  <tr>
			<td width="250" height="116" background="imagens/fundo_estado.gif"><table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
			  <td><div align="center"><span class="estiloNomeTopo">Nenhum evento cadastrado para o estado</span> <span class="TextoTitulo"><% Response.Write(str_ESTADO) %></span></div></td>
			</tr>
		  </table></td>
	  </tr>
		  <tr>
			<td><img src="imagens/fundo_estado_02.gif" width="250" height="134" alt=""></td>
	  </tr>
		</table></td>
  </tr>
</table>
<%
else
While Not Rs.Eof
%>
<table width="390" border="0" cellpadding="0" cellspacing="0" bgcolor="#0066FF">
  <tr>
	<td>
	<table width="390" border="0" cellpadding="3" cellspacing="3">
  
  <tr>
	<td height="35" colspan="4" class="TabelaReunioes"><div align="center" class="TextoTitulo"><%=Rs("tipo")%> </div></td>
	</tr>
  <tr>
	<td width="70" height="25" class="TabelaReunioes"><strong>Data:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("data")%> - <%=Rs("dia_semana")%> às <%=Rs("hora")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Local:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("local")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Endereço:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("endereco")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Cidade:</strong></td>
	<td width="142" height="25" class="TabelaReunioes"><%=Rs("cidade")%></td>
	<td width="48" height="25" class="TabelaReunioes">Estado:</td>
	<td width="130" height="25" class="TabelaReunioes"><%
Select Case (Rs("estado"))
	Case("AC") : Response.Write("Acre")
	Case("AL") : Response.Write("Alagoas")
	Case("AP") : Response.Write("Amapá")
	Case("AM") : Response.Write("Amazonas")
	Case("BA") : Response.Write("Bahia")
	Case("CE") : Response.Write("Ceará")
	Case("DF") : Response.Write("Distrito Federal")
	Case("ES") : Response.Write("Espírito Santo")
	Case("GO") : Response.Write("Goiás")
	Case("MA") : Response.Write("Maranhão")
	Case("MT") : Response.Write("Mato Grosso")
	Case("MS") : Response.Write("Mato Grosso do Sul")
	Case("MG") : Response.Write("Minas Gerais")
	Case("PA") : Response.Write("Pará")
	Case("PB") : Response.Write("Paraíba")
	Case("PR") : Response.Write("Paraná")
	Case("PE") : Response.Write("Pernambuco")
	Case("PI") : Response.Write("Piauí")
	Case("RJ") : Response.Write("Rio de Janeiro")
	Case("RN") : Response.Write("Rio Grande do Norte")
	Case("RS") : Response.Write("Rio Grande do Sul")
	Case("RO") : Response.Write("Rondônia")
	Case("RR") : Response.Write("Roraima")
	Case("SC") : Response.Write("Santa Catarina")
	Case("SP") : Response.Write("São Paulo")
	Case("SE") : Response.Write("Sergipe")
	Case("TO") : Response.Write("Tocantins")
End Select
	%></td>
  </tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Contato:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("contato")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Telefone</strong>:</td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("telefone")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Custo:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes">R$ <%=Rs("custo")%></td>
	</tr>
  <tr>
	<td height="25" class="TabelaReunioes"><strong>Obs:</strong></td>
	<td height="25" colspan="3" class="TabelaReunioes"><%=Rs("obs")%></td>
	</tr>
</table></td>
  </tr>
</table>
<%
Rs.MoveNext : Wend
End if
Set Rs = Nothing
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não precisava fazer tantos if's pra isso td, é só usar elseif:

 

if X = "A" then

...

elseif X = "B" then

...

elseif X = "C" then

...

else

...

end if

 

No caso, se X for igual a A, então vai realizar tal ação, se não for igual a A e for igual a B, vai realizar tal ação, se não for igual a A e B e for igual a C, realiza tal ação, se for diferente de A, B e C, realiza outra ação.

 

Entende? É mais fácil...

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.