Difficulty in Loops While and Foreach

0

I've been studying php a short time so I did not understand the structure of the loops correctly as while and foreach would like someone to explain to me why this while does not display anything, and when I try to use foreach of the error. Thanks in advance for your understanding and patience.

<div id="resultado">
  <table width="100%">
    <thead>
      <tr align="center">
        <th align="center"class="filter-match" data-placeholder="">ID|</th>

        <th align="center"class="filter-match" data-placeholder="">|Cliente|</th>

        <th align="center"class="filter-match" data-placeholder="">|Data Retorno|</th>

        <th align="center" data-placeholder="">|Nome do Contato|</th>  

        <th height="24" data-placeholder="">|Assunto</th>

        </tr>
      </thead>
      </div>

<tbody>



  <tr align="center" >
<?php 


    $acompanhamento = mysql_query("SELECT id_cliente, cliente_nome, data_ret, nome, mensagem FROM acompanhamento 
    WHERE data_ret = '".date('Y-m-d')."' ");
   while ($exibe = mysql_fetch_array($acompanhamento)){
       echo
                           $exibe["id_cliente"];
                            $exibe["nome"];
                            $exibe["mensagem"];
                            $exibe["cliente_nome"];
                            $exibe["data_ret"];

   };


    echo   $id_cliente;    
           $cliente_nome; 
           $data_ret;      
           $nome;          
           $mensagem;  






    ?>  


    </tr>
  </tbody>

</table>



//--------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------

<div id="resultado">
 <table width="100%">
    <thead>
      <tr align="center">
        <th align="center"class="filter-match" data-placeholder="">ID|</th>

    <th align="center"class="filter-match" data-placeholder="">|Cliente|</th>

    <th align="center"class="filter-match" data-placeholder="">|Data Retorno|</th>

    <th align="center" data-placeholder="">|Nome do Contato|</th>  

    <th height="24" data-placeholder="">|Assunto</th>

    </tr>
  </thead>
  </div>

<tbody>



  <tr align="center" >
<?php 


    $acompanhamento = mysql_query("SELECT id_cliente, cliente_nome, data_ret, nome, mensagem FROM acompanhamento 
    WHERE data_ret = '".date('Y-m-d')."' ");
   $exibe = mysql_fetch_array($acompanhamento)
   foreach mysql_fetch_array($acompanhamento) as $value)
            {
       echo
                           $exibe["id_cliente"];
                            $exibe["nome"];
                            $exibe["mensagem"];
                            $exibe["cliente_nome"];
                            $exibe["data_ret"];

   };


    echo   $id_cliente;    
           $cliente_nome; 
           $data_ret;      
           $nome;          
           $mensagem;  






    ?>  


    </tr>
  </tbody>

</table>
    
asked by anonymous 19.04.2018 / 15:43

1 answer

0

1st Check if you have correctly connected to the bank

2º Use single quotes                             $ displays ['customer_id'];                             $ displays ['name'];                             $ displays ['message'];                             $ displays ['client_name'];                             $ displays ['data_ret'];

3rd place any echo within the repeater to know if it is performing as it should, maybe it is not even entering the while.

4th You made 1 Echo and used a semicolon after every $ displays, it is only necessary; in the last variable.

    
19.04.2018 / 16:33