$value = '';
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了三台免费建站欢迎大家使用!
$query_num = 5; //插入数量
for($i=1;$i=$query_num;$i++){
$value .= "('25','1')";
}
//mysql insert有插入多条语法,拼接sql语句,table_name表名
$sql = "insert into table_name (memid,online) values ".$value;
//执行,插入$query_num条数据
mysql_query($sql);
$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换你购物车里的内容,应该就可以了
你还是用循环吧。
$arr=explode("|||",$reply);
$query="insert
into
{$cfg_dbprefix}askanswer
(askid,
ifanswer,
tid,
tid2,
uid,
username,
anonymous,
userip,
brief,
dateline,
content,
ifcheck)
";
//循环构造sql语句
foreach($arr
as
$v)
{
$sql.=",values('$askid',
'1',
'$tid',
'$tid2',
'$uid',
'$username',
'$anonymous',
'$userip',
'$brief',
'$timestamp',
'$v',
'0')";
}
//去掉第一个‘,’号
$sql=$query.substr($sql,1);
//插入语句
$dsql-ExecuteNoneQuery($sql);
到这就可以了。
$sql = "insert into myorder (pid,amount,ordernumber,time,uid,status) VALUES ";
foreach ($ShoppingCart as $k = $v){
$sql .= "(".$v['pid'].",".$v['amount'].",'$ordernumber','$time','$uid','$status'),";
$sql = substr($sql, 0,strlen($sql)-1);
$res = mysql_query($sql,$conn);
if(!$res) return false;
}