我有一个包含 1 列的表,用于存储 ID auto_increment 并使用该指令:
$query = "SELECT first_data, second_data, third_data
FROM table_data
WHERE condition = 'value_condition'";
$result = mysql_query($query) or die(mysql_error());
$no_of_rows = mysql_num_rows($result);
if ($no_of_rows > 0) {
while($row = mysql_fetch_assoc($result)) {
$valueone = $row['first_data'];
$valuetwo = $row['second_data'];
$valuethree = $row['third_data'];
$queryTwo = "INSERT INTO historial_ventas (reg1, reg2, reg3)
VALUES('$ivalueone','$valuetwo','$valuethree')";
$resultTwol = mysql_query($queryTwo) or die(mysql_error());
}
} else {
return false;
}
信息存储如下:
ID(auto_increment) reg1 reg2 reg3
______________________________________________
1 value1 value2 value3
2 value1 value2 value3
3 value1 value2 value3
4 value1 value2 value3
但我希望在 while 循环中维护记录,使用与在线购买相同的 ID 存储,即您保存产品及其功能但使用相同的 ID 购买,如下所示:
ID(auto_increment) reg1 reg2 reg3
______________________________________________
1 value1 value2 value3
1 value1 value2 value3
1 value1 value2 value3
1 value1 value2 value3