PHP mysql INSERT一次插入多条表单数据的方法

2024-10-27 15:17:55
推荐回答(1个)
回答1:

$sql = "insert into myorder (pid,amount,ordernumber,time,uid,status) VALUES ";
foreach ($gouwuche as $k => $v) {
$sql .= "(".$v['pid'].",".$v['amount'].",'$ordernumber','$time',1,0),";
}
$sql = substr($sql, 0,strlen($sql)-1);
把$gouwuche换你购物车里的内容,应该就可以了