0
// open csv 
$handle = fopen("update.csv", "r");

// select cols
while (($data = fgetcsv($handle, 1000, ";")) !== false) {
$model = mysql_real_escape_string ($data[0]);
$price = mysql_real_escape_string ($data[5]);
$quantity = mysql_real_escape_string ($data[7]);
mysql_select_db("verradt33_develop", $link);

// replace comma with period and text with numbers
$price = str_replace(",", ".", $price);
$quantity = str_replace("JA", "10", $quantity);
$quantity = str_replace("NEE", "0", $quantity);

// execute
$result = mysql_query("UPDATE dev_product SET price='$price' , quantity='$quantity'     WHERE model='$model'")
or die(mysql_error());

上面的代码有效。现在我想知道是否可以计算$price排除增值税(21%)的价格。

例子:

CSV 给出1.99. 但是我想1.6446被插入到数据库中。
1.99 / 121 x 100不含增值税)

4

1 回答 1

0

只需添加/1.21

UPDATE dev_product 
SET price = $price / 1.21, 
    quantity = $quantity 
WHERE model = '$model'
于 2013-07-07T12:15:03.757 回答