Ir para conteúdo

POWERED BY:

Arquivado

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

Marcello-Master

Aparece o Ultimo Registro !?!?!?!?

Recommended Posts

E ai Galera beleza, será que vcs podem me ajudar a descobrir o que está acontecendo ???!!!!!é o seguinte eu tenho uma pagina que tem uma lista de registros e sempre que clico em um deles ele me mostra direto o ultimo registro cadastrado na pagina de detalhes e não o que eu cliquei e gostaria que mostrasse, estou colocando o codigo das duas paginas abaixo:Se alguem puder me ajudar eu agradeço:Pagina que tem a lista de registros.

<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <div align="center"><img src="img/cabeca-casas.gif" width="596" height="49"></div> </td> </tr> <tr> <td background="../imagens/cabeca-fundo.gif"> <% 'set rs=con.execute("select * from login where login='"&vlogin&"' and senha='"&vsenha&"'") intConta = 1imovel = "select * from imovel where tp_imovel='Casa'"set imovel_rs = cn.Execute(imovel)if imovel_rs.BOF AND imovel_rs.EOF then response.write "Nenhum Imovel cadastrado no momento."else while NOT imovel_rs.EOF AND intConta <=5000 intConta = intConta + 1 %> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="3%"><img src="../imagens/borda-esquerda.gif" width="29" height="109"></td> <td width="94%" background="../imagens/borda-fundo.gif"> <table width="100%" border="0" cellpadding="5" cellspacing="0" align="center"> <tr> <td width="22%"><a href="house_detalhe.asp?area=detalhes&id_imovel=<%response.Write(imovel_rs("id_imovel"))%>"><img src="<%response.Write(imovel_rs("imagem02"))%>" width="120" height="80"></a></td> <td width="78%" class="texto8"><%response.Write(imovel_rs("desc_simples"))%><br><font class="texto8boldred"><% response.Write(imovel_rs("valor"))%></font><br><font class="texto8bold"><% response.Write(imovel_rs("referencia")) %></font><br><%response.Write(imovel_rs("desc_negrito01"))%> </table></td> <td width="3%"><img src="../imagens/borda-direita.gif" width="29" height="109"></td> </tr> </table> <br> <%imovel_rs.MoveNextWendend ifimovel_rs.Closeset imovel_rs = nothing%></td> </tr> <tr> <td background="../imagens/cabeca-fundo.gif"><img src="../imagens/rodape.gif" width="596" height="49"></td> </tr> </table>

Pagina que mostra os detalhes do registro e que está mostrando o Ultimo ao inves do que foi clicado.

<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> </td> </tr> <tr> <td> <%if id_imovel <> 0 then s = "select * from imovel where id_imovel = " & id_imovel & " AND ativo = True"else s = "select * from imovel where ativo = True ORDER BY id_imovel DESC"end ifset ls = cn.Execute(s)if ls.BOF AND ls.EOF then%><%else ls.MoveFirst id_imovel = ls("id_imovel")%><br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr> <td><div align="center"><img src="<% response.write ls("imagem02") %>" width="400" height="267"></div></td> </tr> <tr> <td><div align="center"> <% response.write ls("desc_negrito02") %> </div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="86"> </td> <td width="388"><% response.Write Replace (ls("desc_imovel"), Vbcrlf, "<br>")%></td> <td width="123"> </td> </tr> <tr> <td> </td> <td><% response.Write Replace (ls("valor"), Vbcrlf, "<br>")%></td> <td> </td> </tr> <tr> <td> </td> <td><% response.Write Replace (ls("referencia"), Vbcrlf, "<br>")%></td> <td> </td> </tr> </table></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> <% end ifls.Closeset ls = nothing%> <br> <% 'set rs=con.execute("select * from login where login='"&vlogin&"' and senha='"&vsenha&"'") intConta = 1imovel = "select * from imovel where tp_imovel='Casa'"set imovel_rs = cn.Execute(imovel)if imovel_rs.BOF AND imovel_rs.EOF then%><% response.write "Nenhum Imovel Cadastrado nesta Categoria no momento."else while NOT imovel_rs.EOF AND intConta <=5000 intConta = intConta + 1 %> <br> <%imovel_rs.MoveNextWendend ifimovel_rs.Closeset imovel_rs = nothing%></td></tr> <tr> <td> </td> </tr> </table>

Ai galera fico agradecido pela força. http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

no inicio da página de detalhes você tem que recuperar a querystring antes de executar o sql<%id_imovel =request.querystring("id_imovel")if id_imovel <> 0 thens = "select * from imovel where id_imovel = " & id_imovel & " AND ativo = True"elses = "select * from imovel where ativo = True ORDER BY id_imovel DESC"end if

Compartilhar este post


Link para o post
Compartilhar em outros sites

JonathanDJ , eu recuperando apenas o Id_imovel resolveria ou tenho que recuperar todas as informações que vou utilizar nesta outra pagina de detalher ?Sem abusar de você, será que teria como me explicar o que exatamente o que essa linha fazid_imovel =request.querystring("id_imovel")Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ai JonathanDJ Valew meu velho deu certinho....Se você puder me explicar o que significa o id_imovel =request.querystring("id_imovel") faz exatamente eu agradeço desculpa minha ignorancia mas estou tentando aprender de maneira que eu possa saber exatamente o que faz os comandos....Obrigado mais uma vez

Compartilhar este post


Link para o post
Compartilhar em outros sites

não é ignorancia sua, ninguem nasce sabendo...é bom saber que você tem interesse em aprender e não simplesmente "alugar' o pessoal pra resolver as coisas....segue...

apenas foi feito o seguinte....

No link que você fez está assim

<a href="house_detalhe.asp?area=detalhes&id_imovel=<%response.Write(imovel_rs("id_imovel"))%>"><img src="<%response.Write(imovel_rs("imagem02"))%>" width="120" height="80"></a>

id_movel está recebendo um valor do recordset quando clicamos no link esse valor vai ser escrito na URL

 

request.querystring recupera esse valor(em negrito) que foi passado pela URL(endereço do browser), então colocamos ele numa variavel (id_imovel) para utilizarmos depois

o proximo passo é verificar se a variavel está vazia ou diferente de nulo

if id_imovel <> 0 then

s = "select * from imovel where id_imovel = " & id_imovel & " AND ativo = True"

else

s = "select * from imovel where ativo = True ORDER BY id_imovel DESC"

end if

Se a variavel id_imovel estiver com algum valor diferente de 0 então executa o select usando o where de parametro. Se não for <> 0 então puxa todos os registros ativos

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.