這裏的問題是需要一些幫助PHP的MySQL
$rd = do_mysql_query("SELECT sum(product_price * '{$count}') as letsee
FROM prices
WHERE product_id = '{$record['prodid']}'
AND id='{$id_p}'
ORDER BY product_id") or sqlerr(__FILE__, __LINE__);
while($row = mysqli_fetch_array($rd)){
echo "{$record['prodid']}:{$row['letsee']}<br />"; //id:count
}
它爲我
10:130
10:95
7:88
6:35
6:120
6:330
11:104
11:64
我需要加用ID
所需結果的所有罪名
- 10:225
- 7:88
- 6:485
- 11:168
感謝
使用GROUP BY! https://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html – Neels
如果我添加GROUP BY product_id。它顯示了相同的結果 – Nazaret2005
嘗試GROUP BY product_id,product_price – Neels