Reputation: 329
I have the following code:
<td class="dataTableContent">
<?php
$cuttinglist_weight_query = tep_db_query("select op.orders_id, p.products_id, SUM(p.products_weight) as total_products_weight from " . TABLE_ORDERS_PRODUCTS . " op left join " . TABLE_PRODUCTS . " p on (op.products_id = p.products_id) where orders_id = '" . (int)$cuttinglist['orders_id'] . "'");
$cuttinglist_weight = tep_db_fetch_array($cuttinglist_weight_query);
echo $cuttinglist_weight['total_products_weight'];
?>
</td>
this prints the Total weight of Order column:
In the box below titled 'total weight to prepare', I need to show the total of the column, anyone have any ideas?
Upvotes: 0
Views: 359
Reputation: 39704
<td class="dataTableContent">
<?php
$cuttinglist_weight_query = tep_db_query("select op.orders_id, p.products_id, SUM(p.products_weight) as total_products_weight from " . TABLE_ORDERS_PRODUCTS . " op left join " . TABLE_PRODUCTS . " p on (op.products_id = p.products_id) where orders_id = '" . (int)$cuttinglist['orders_id'] . "'");
$cuttinglist_weight = tep_db_fetch_array($cuttinglist_weight_query);
echo $cuttinglist_weight['total_products_weight'];
if(!$totalSum){ $totalSum = 0; }
$totalSum += $cuttinglist_weight['total_products_weight']
?>
</td>
then at the end in your cell just echo it:
<table>
<tr>
<td>Total Weight To Prepare</td>
</tr>
<tr>
<td><?php echo $totalSum; ?></td>
</tr>
</table>
Upvotes: 2