if($_SESSION['cart']) { foreach($_SESSION['cart'] as $product_id => $quantity) { $say=1; $result = mysql_query(sprintf("SELECT isim, kod, fiyat FROM urunler WHERE id = %d;",$product_id)); if(mysql_num_rows($result) > 0) { $record = mysql_fetch_assoc($result); $name = $record['isim']; $kod = $record['kod']; $price = $record['fiyat']; $line_cost = $price * $quantity; $total = $total + $line_cost; } $say++; } }