我正在尝试将具有类似ID的行(在本例中为order_id)组合在一起。我想在一个单独的表中将每组相似的id。我的状态查询显示一个表中的所有行。我不知道该怎么做。
这是我的代码:
<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>