As the title says i'm developing shopping cart for a website and the cart contains all the products that been ordered from different companies like this :- screenshot
so as you see i'm trying to sort all products that is from the same company underneath each other as the specific company bill my question how can i accomplish that ?
what i have tried :- nothing to mention actually i'm really so confused here i don't now what i'm going to (loop for or something like that .. ) i hope i explained what i want to accomplish, if not (screenshot) code :- php PDOquery
<?
$accountid = '8';
require_once '..\Config.php';
// WHERE chemicalcom='$variable' OR name='$variable'
$dbCon = "mysql:host=$host;dbname=$db_name";
$variable = "Efexor";
$PDOCon = new PDO($dbCon, $username, $password);
$query = $PDOCon->prepare("SELECT * FROM basket WHERE accountid ='$accountid'");
$query->execute();
$basketItems = $query->fetchAll();
?>
code :- index.php
<? foreach($basketItems as $item){
echo'<h3>Bill('.$item['companyexported'].')</h3>
<div class="card">
<div class="row">
<div class="col-6"><img src="'.$item['imgpath'].'" class="productimg" alt=""></div>
<div class="col-auto">
<div class="card-title">
<div class="row">'.$item['name'].'</div>
<div class="row">'.$item['chemicalcom'].'</div>
<div class="row">'.$item['concentration'].'</div>
<br>
<div class="row">'.$item['price'].' $
</div>
<span class="badge badge-info qty">'.$item['qty'].'</span>
</div>
</div>
</div>
</div>';}?>
Thanks .