How to display data group by $vendorid, When I order 5 products from different vendors.
Ex : Random added products to cart.
| $vendorid | $product_name |
-----------------------------
| 1 | TEST31 |
| 4 | TEST21 |
| 3 | TEST20 |
| 3 | TEST17 |
| 4 | TEST11 |
But I want to display like this :
| $vendorid | $product_name |
-----------------------------
| 1 | TEST31 |
| 3 | TEST20 |
| 3 | TEST17 |
| 4 | TEST21 |
| 4 | TEST11 |
Code :
foreach($_SESSION["products"] as $product){
$product_name = $product["p_name"];
$vendorid = $product["p_member_id"];
$cart_box = "<li>$vendorid $product_name</li>";
}
echo $cart_box;
This gives me an output in the same result that I've added to cart like this :
| $vendorid | $product_name |
-----------------------------
| 1 | TEST31 |
| 4 | TEST21 |
| 3 | TEST20 |
| 3 | TEST17 |
| 4 | TEST11 |
ORDER BY p_member_id;ODER BY p_member_id ASCat last....$_SESSION['products'][] = $newitem;is executed (without hitting the database at this stage).