Ben alışveriş sepeti bir yanlış fiyat var ne zaman, 2 dizilerin içeriğini karşılaştırmak çalışıyorum temelde ben bir alışveriş sepeti kullanarak ve ben bir veritabanına karşı gönderilen formların fiyatları kontrol etmek gerekir, sorun bana verir Ben 1 doğru fiyat ve 1 o kasada devam yanlış, ben yanlış yapıyorum bilmiyorum bir hata mesajı ancak herhangi bir yardım mutluluk duyacağız.
foreach ($cart->get_contents() as $item)
{
$item_id = $item['id'];
$item_name = $item['name'];
$item_price = $item['price'];
$item_qty = $item['qty'];
$connection = mysql_connect($dbhost,$dbuser,$dbpass) or die("Error connecting to mysql");
mysql_select_db($dbname);
$query = "select * from products where product_name = '$item_name'";
$result = mysql_query($query);
if (!$result) {
echo mysql_error();
}
while ($row = mysql_fetch_assoc($result)) {
$sql_price[] = $row['product_price'];
$qty[] = $row['product_qty'];
$name = $row['product_name'];
}
foreach($sql_price as $price) {
$price = $price;
if ($price !== $item_price) {
$valid_prices = false;
}else{
$valid_prices = true;
}
}
}
if ($valid_prices !== true)
{
// KILL THE SCRIPT
die($jcart['text']['checkout_error']);
}