I am using this while loop in order to echo some data:
$arr = array();
while ($row = mysqli_fetch_assoc($result)) {
$tip= $row["tip"];
$name= $row["name"];
$qty= $row["qty"];
$arr = "\n".$tip. "" .$qty."x " .$name;
echo "<pre>";
print_r($arr);
echo "</pre>";
}
And getting those results:
Food 1x Hambuger
Food 1x Pizza
Food 1x Milk
Food 1x Wine
Sports 2x Shirt
Sports 1x Gloves
Sports 1x Shoes
However, this is my expected result:
Food
1x Hambuger
1x Pizza
1x Milk
1x Wine
Sports
2x Shirt
1x Gloves
1x Shoes
Should be use array unique?
Thanks!
$row["tip"]to$tip, see if they are equal. If not, output$row["tip"](and a newline), and then assign to$tip. If they are, don't output.