Remove duplicate records from select php array

Asked

Viewed 108 times

0

I cannot remove duplicate records in the array

$query = $pdo->prepare("SELECT * FROM produtos order by Data asc");
$query -> execute();
$ContCampos = $query -> rowCount();

$consulArray = array();

while($consulta = $query ->fetch(PDO::FETCH_ASSOC)){
    $consulArray[] = array_unique($consulta);

}

foreach($consulArray as $copia1)
{
    $nome = $copia1['Nome'];
        echo '<option>'.$nome.'</option>';

} 

print_r($nome);

I searched the comic book, and I need you to return the date and the name, but not return duplicate data! has the option to use the select distincs but did not want to use it! I don’t know why the array_unique is not filtering, if someone can help me!

Select result

Array ( [0] => Array ( [id] => 83 [Nome] => Ana Carla Pagung [Verdura] => QUIABO [Quantidade] => 2 [Observacao] => [Unidade] => KILOS [Data] => 2018-05-07 ) 

[1] => Array ( [id] => 84 [Nome] => Ana Carla Pagung [Verdura] => QUIABO [Quantidade] => 25 [Observacao] => [Unidade] => CAIXAS [Data] => 2018-04-05 ) 
  • within the array have any values that are unique to the record? type an ID? You will only use the same name in the example?

  • 1

    I put the print_r result, I need in case the Date and Name that is in the array

  • So in this case it has no iguas values, they are different requisitions, but of the same person

  • You want to do exactly what? display what?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.