Ir para conteúdo
Fórum Script Brasil
  • 0

Problemas Na Hora De Listar


AnD

Pergunta

Olá Galera,

Meu site www.alphamasterimoveis.com.br, lista os imóveis, aletoriamente. Os imóveis que não tem foto, eu coloquei para aparecer uma imagem com o nome de sem_nome.jpg.

Meu cliente, agora não quer mais assim, ele quer que apareça somente os imóveis que tem foto. O código atual é este:

<table width="150" border="0" cellspacing="0" cellpadding="0">
  
          <tr>
            <td width="10">&nbsp;</td>
            <td><table width="130" border="0" cellspacing="0" cellpadding="0" <%=rs_site("cor_fundo_destaque")%>>
              <tr>
                <td ><table width="130" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="22" align="center" valign="middle" background="arquivos/imagens/borda_cima.gif"><div align="center"><font color="#006699" class="texto_02_cinza_bold">
                            <%
       SQL_TIPO = "SELECT * FROM imoveis WHERE categoria='" & categoria & "'"
       SET RS_TIPO = Server.CreateObject("AdoDB.RecordSet")
       RS_TIPO.Open SQL_TIPO,Conexao,3,3
       imovel = RS_TIPO.GetRows()
       rs_TIPO.close
                      Randomize Timer()
                      Registro  = Int((UBOUND(imovel, 2) +1) * Rnd)

       %>
                            <%=Imovel(3, Registro)%></font></span>
                            </div>
                    </div></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="100" align="center" valign="middle" class="tabela_esq_dir_vermelho"><table width="10" height="10" border="0" cellpadding="0" cellspacing="0" class="tabela_toda_cinza">
                    <tr>
                      <td valign="bottom">
       <% SQL_FOTOS2 = "SELECT TOP 1 * FROM fotos WHERE idimovel='" & Imovel(0, Registro)  & "'"
       SET RS_FOTOS2 = Server.CreateObject("AdoDB.RecordSet")
       RS_FOTOS2.Open SQL_FOTOS2,Conexao
       
       if NOT RS_fotos2.eof then
       %>
                          <a href=detalhes_imovel.asp?id=<%=Imovel(0, Registro)%>><img src="<%=rs_site("local_imoveis")%><%=rs_fotos2("foto")%>" width="120" height="90" border="0"></a>
        <% else %>
        <a href=detalhes_imovel.asp?id=<%=Imovel(0, Registro)%>><img src="<%=rs_site("local_imoveis")%>sem_foto.jpg" width="120" height="90" border="0"></a>
        <% end if %>        </td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td height="20" class="tabela_esq_dir_vermelho"><table width="124" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td height="24" valign="top" class="texto_02_cinza"><%=left(Imovel(20, Registro),35)%>...</td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="130" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="20" height="20" align="right" valign="top"><img src="arquivos/imagens/borda_destaque_esq_baixo.jpg" width="20" height="20"></td>
                      <td class="tabela_baixo_vermelho">&nbsp;</td>
                      <td width="20" height="20" valign="top"><img src="arquivos/imagens/borda_destaque_dir_baixo.jpg" width="20" height="20"></td>
                    </tr>
                </table></td>
              </tr>
            </table></td>
            <td width="10">&nbsp;</td>
  	
          </tr>
    
        </table><%
n = n + 1
RS_Imoveis.Movenext
If n > c then
response.write "</tr>"
n = 1
end if
loop
%>

Quando insiro o imóvel, o endereço da foto vai para uma tabela, e os dados do imóvel para outra. Eu creio que eu vou ter que dar um INNER JOIN para ele listar somente os imóveis com fotos. Mas não estou sabendo fazer.

Vlw!

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Hum..

Complicado, né?

Vamos ver se captei os dados:

1- Select que pega os imoveis:

SQL_TIPO = "SELECT * FROM imoveis WHERE categoria='" & categoria & "'"
2- Select que pega a imagem:
SQL_FOTOS2 = "SELECT TOP 1 * FROM fotos WHERE idimovel='" & Imovel(0, Registro)  & "'"

Os SQL's seriam estes, né?

Então, você quer juntar os dois, num só, e mostrar só as imagens com Foto?

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...