我有報告顯示出售的產品以及每種產品的總重量。下面是代碼的標記,顯示總重量:在沒有數據的情況下返回設定值
$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