I have three colums which has same values for two of the rows. I want to print only one of a same row out of the two same rows using a php while loop statement. This is how the data is
ID values
1 MINI
1 MINI
2 MINI
I want to print all of these but only once with same rows based on the ID
ID Values
1 MINI
2 MINI
I can actually use DISTINCT OR GROUP BY in mysql query to find the expected answer above but I really need to use a php while statement.
This is what I have been trying my hands on
$query="SELECT * from table";
$sR=$db->query($query);
$array=array();
while($sRow=mysqli_fetch_assoc($sR)){
$ID=$searchRow['ID'];
$values=$searchRow['Values'];
$array[$ID][]=$ID;
$array2[$ID][]=$values;
}
foreach($array as $ID => $item){
$value=$array[$ID];
foreach($item as $newItem){
if($newItem===$newItem){
echo '---'.$newItem;
break;
}
}
}
This is what I am trying hands on but it doesn't seem to work as expected, I would need help on it. Thanks soo much.