0

我有以下代码:

<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>

这将打印订单列的总重量:

在此处输入图像描述

在下面标题为“要准备的总重量”的框中,我需要显示该栏的总重量,有人有什么想法吗?

4

1 回答 1

2
<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>

然后在你的单元格最后回显它:

<table>
    <tr>
        <td>Total Weight To Prepare</td>
    </tr>
    <tr>
        <td><?php echo $totalSum; ?></td>
    </tr>
</table>
于 2012-09-05T12:43:34.820 回答