是否可以仅使用一个插入查询来简化以下代码?
if(isset($_POST['colore'])) {
$range = array_keys($_POST['colore']);
foreach ($range as $key) {
$colore = $_POST['colore'][$key];
$s = $_POST['S'][$key];
$m = $_POST['M'][$key];
$l = $_POST['L'][$key];
$xl = $_POST['XL'][$key];
$xxl = $_POST['XXL'][$key];
$sql = "INSERT INTO store_product_attributes (`prod_id`, `color`, `size`, `qty`)
VALUES ('$last_id', '$colore', 's', '$s')";
$query = mysql_query($sql) or die(mysql_error());
$sql = "INSERT INTO store_product_attributes (`prod_id`, `color`, `size`, `qty`)
VALUES ('$last_id', '$colore', 'm', '$m')";
$query = mysql_query($sql) or die(mysql_error());
$sql = "INSERT INTO store_product_attributes (`prod_id`, `color`, `size`, `qty`)
VALUES ('$last_id', '$colore', 'l', '$l')";
$query = mysql_query($sql) or die(mysql_error());
$sql = "INSERT INTO store_product_attributes (`prod_id`, `color`, `size`, `qty`)
VALUES ('$last_id', '$colore', 'xl', '$xl')";
$query = mysql_query($sql) or die(mysql_error());
$sql = "INSERT INTO store_product_attributes (`prod_id`, `color`, `size`, `qty`)
VALUES ('$last_id', '$colore', 'xxl', '$xxl')";
$query = mysql_query($sql) or die(mysql_error());
}
}