0
I’ve been studying php for a little while so I didn’t properly understand the structure of the loops as while and foreach I would like someone to explain to me why this while displays nothing, and when I try to use error foreach. Thanks in advance for 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>
Before using the looping gives a var_dump(mysql_fetch_array($accompaniment));
– Marcos Xavier
If you returned something in the query it will display. Remember that the mysql_* functions were discontinued in the current php version
– Marcos Xavier