我有报告显示出售的产品以及每种产品的总重量。下面是代码的标记,显示总重量:在没有数据的情况下返回设定值
$weightsql = 'select op.products_name, sum(op.products_quantity * p.products_weight) as weightsum from ' . TABLE_ORDERS_PRODUCTS . ' op left join ' . TABLE_PRODUCTS . ' p on op.products_id = p.products_id where op.products_id = '.$pro['products_id'];
$weightq = tep_db_query($weightsql);
while ($weight = tep_db_fetch_array($weightq)){
if($category_parent_id != 0)$list_items[] = $weight['weightsum'];
}
它于订购的产品返回值,但无序的产品,它保持空白,这是非常令人困惑。如何为无序产品返回0.00(产品未从查询中拉出)。
例子:
Product Name | Total Weight
|
Jelly Beans | 25.00
Soft Candy | This product has not been ordered, needs to show 0.00
Bubblegum | 10.00
感谢您的快速帮助,它会让我接受答案。 – user1879415
如果我想将正确的值和正常的零值一起用于识别已售出的产品,那么将如何完成? – user1879415
在帖子中回复。 @ user1879415,下一次为新问题写一个新帖子,不要改变问题要求。 – danihp