I am trying to group rows with similar ids (order_id in this case) together. I want each group of similar ids in a separate table. My presence query displays all rows in one table. I don't know how to go about it.
This is my code:
<div class='panel panel-body'>
<table class='table table-condensed'>
<thead>
<tr class='cart_menu'>
<td class='price'>Order ID</td>
<td class='price'>Item(s)</td>
<td class='price'>Quantity</td>
</tr>
</thead>
<tbody>
";
$select = "SELECT DISTINCT a.*, b.* FROM shipping_order a JOIN shipping_details b ON b.order_id = a.order_id WHERE user_id = :user_id AND a.order_id = b.order_id";
foreach ($db->query($select, array('user_id' => $id)) AS $items){
echo"
<tr>
<td class='cart_price'>
<h4>{$items['order_id']}</h4>
</td>
<td class='cart_price'>
<h4><a href=''>{$items['item']}</a></h4>
<!-- <p>Web ID: </p> -->
</td>
<td class='cart_price'>
<p>{$items['quantity']}</p>
</td>
</tr>
";
}
echo"
{$items['total']}
</tbody>
</table>
</div>
Aucun commentaire:
Enregistrer un commentaire