// 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
排除增值税)
答案 0 :(得分:0)
只需添加/1.21
UPDATE dev_product
SET price = $price / 1.21,
quantity = $quantity
WHERE model = '$model'