【发布时间】:2016-02-15 07:11:05
【问题描述】:
我正在使用我最近开始学习的 PHP 和 MySQL 创建一个基本的电子商务网站。我有一个具体的问题。每当我添加两个同名产品时,都会将重复的产品添加到数据库中。有没有办法避免同样的情况,而是增加数量的数字。
else{
$product_image = addslashes(file_get_contents($_FILES['fileField']['tmp_name']));
include_once("../scripts/connect.php");
$sql = mysql_query("INSERT IGNORE INTO products(name, brand, category, sizes, description, price, quantity, product_image, date_added) VALUES('$product_name','$product_brand','$product_category','$product_sizes','$product_description','$product_price','$product_quantity','$product_image', now())");
$id = mysql_insert_id();
$msg = "Success!";
}
【问题讨论】:
-
添加商品的代码是什么?
标签: php mysql e-commerce