Jump to content
Fórum Script Brasil
  • 0

Concatenar nome da variavel


Carlos Rocha

Question

Olá pessoal.

Tenho um foreach que varre os indices de um array.

Nesse foreach, gostaria de colocar uma consulta que iria se repetir para cada value do for each. Para cada value do foreach, terei uma pesquisa e como resultado dessa pesquisa, um while list.

Com,o faz isso?

Tentei assim(mas só lista os dados do ultimo registro):

<?php
     foreach ($imoveis as &$value) 
     {
         $sql_busca_imovel_string.$value=
               "
                 select 
                   imoveiscadastrovenda.id_imovel, 
                   imoveiscadastrovenda.bairro_imovel, 
                   (select fotos.nome_fotos from fotos where fotos.id_imovel_fotos = imoveiscadastrovenda.id_imovel limit 1) as foto
                 from 
                   imoveiscadastrovenda
                 where 
                   imoveiscadastrovenda.imovel_tipo_imovel=$value and imoveiscadastrovenda.baixa_imovel='n'   
                 group by                 
                   imoveiscadastrovenda.id_imovel
                 limit 0,5
                ";
         $sql_busca_imovel.$value=$MySQL->query($sql_busca_imovel_string.$value);

         while(list($id_imovel, $bairro_imovel, $foto) = mysql_fetch_row($sql_busca_imove.$value))
         {
             print $bairro_imovel."<br>";
             print $foto."<br>";
         }
     }
?>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...