function total_price($cart) {
$total_price = 0.0;
db_connect(); /* тоже на mysql */
if(is_array($cart)){
foreach($cart as $id => $qty) {
$query = "SELECT price FROM sdvd_products WHERE id = '$id'";
$result = mysql_query($query);
if($result){
$item_price = mysql_result($result,0,'price');
$total_price += $item_price * $qty;
}
}
}
return $total_price;
}
function total_price($cart) {
$total_price = 0.0;
db_connect(); /* Надо переписать на mysqli */
if(is_array($cart)){
$query = $mysqli->prepare("SELECT `price` FROM `sdvd_products` WHERE `id` = ?");
$query->bind_param('i', $id);
$query->bind_result($item_price);
foreach($cart as $id => $qty) {
$query->execute();
if ($query->fetch())
$total_price += $item_price * $qty;
}
$query->close();
}
return $total_price;
}