我为小餐馆建造购物车。我有项目数据库
item_id
item_name
item_price1 (normal)
item_price2 (with discount)
item_category
购物车MySQL
shoping_card_id
shoping_card_session
shoping_card_item (item_id)
shoping_card_quantity
我用这个查询打电话给我的购物车
$shoping_card_session = $_SESSION['ime'];
$rezultat = mysqli_query($link, "SELECT * FROM shop_kosarica WHERE shoping_card_session='$shoping_card_session' AND shoping_card_quantity<>0 ORDER BY shoping_card_id ASC");
$num_results = mysqli_num_rows($rezultat);
if ($num_results==0){
echo "<h2><strong>Card is empty</strong></h2><br><br>";
}else{
while ($redak = mysqli_fetch_array($rezultat)){
$item_id = $redak['shoping_card_item'];
$rezultat_artikal = mysqli_query($link, "SELECT * FROM shop_artikal WHERE item_id='$item_id'");
$redak_artikal = mysqli_fetch_array($rezultat_artikal);
.....some code...
}
但是现在客户想要查询自动计算,如果有3个或更多项目与item_category 6,并在该项目上计算折扣价格-15%。所以要显示item_price1的字段item_price2的价格。 (我已经计算了价格折扣并将其放在字段item_price2中)。有什么想法吗?