I have a table in the bank called orders, where the number of the control can be duplicated, since the customer in the same order can buy 2 items, ie each line will insert a purchased product but with the same control number, and I wanted to show the products bought, show only one, and then when I click I will show the rest, but in the view I need them to bring me only 1, it may be the last record of that control, and not duplicated as is coming. I do not know if I was clear.
<table class="table">
<thead>
<tr>
<th scope="col">Número pedido</th>
<th scope="col">Data</th>
<th scope="col">Valor</th>
<th scope="col">Situação</th>
</tr>
</thead>
<?
$result = ("SELECT * FROM pedidos WHERE id_cliente = '".$usr_id."' ORDER BY id DESC");
$execute = mysqli_query($conn, $result);
if(mysqli_num_rows ($execute) > 0 )
{
while ($dados_cliente = mysqli_fetch_assoc($execute)){
$data = $dados_cliente['data'];
$controle = $dados_cliente['identificacao_pedido'];
$valor_pedido = $dados_cliente['valor_pedido'];
$valor_frete = $dados_cliente['valor_frete'];
$situacao = $dados_cliente['situacao'];
$total = $valor_pedido+$valor_frete;
if ($situacao=='ag') {
$exibir_situacao = 'Aguardando Pagamento';
}
elseif ($situacao=='ap') {
$exibir_situacao = 'Pagamento Aprovado';
}
elseif ($situacao=='cn') {
$exibir_situacao = 'Pagamento Cancelado';
}
elseif ($situacao=='sp') {
$exibir_situacao = 'Em separação';
}
elseif ($situacao=='tr') {
$exibir_situacao = 'Em transporte';
}
elseif ($situacao=='en') {
$exibir_situacao = 'Pedido Entregue';
}
?>
<tbody>
<tr>
<th scope="row">#<?=$controle;?></th>
<td><?=$data;?></td>
<td>R$ <?=number_format($total,2,',','.');?></td>
<td><span><strong><?=$exibir_situacao;?></strong></span></td>
</tr>
</tbody>
<?}}else{?>
<table class="table table-striped table-dark">
<center>Você não efetuou nenhum pedido ainda.</center>
</table>
<?}?>
</table>