
//如果大于100条就每次写入100,休息1秒,然后继续写,直到写完为止
$write_count = floor($strleng/100)
while ($write_count > 0){
for ($i=0$i<100$i++){
echo "INSERT INTO tbl_name (a,b,c) VALUES(1,2,3)"//写100次就休息
}
//echo "INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9)"这样可以一次插入多条数据,效率更高
//参考https://dev.mysql.com/doc/refman/5.7/en/insert.html
$write_count -=1
sleep(1)
echo '休息1秒'
}
}
html页面<form name="form" method="post" action="test.php">
<input type="hidden" name="new_id" value="123" /><input type="text" name="new_title[]" value="爱就爱" size="70" style="height:20px" />
<input type="hidden" name="new_id" value="1asdfsd23" /><input type="text" name="new_title[]" value="爱sdfsdfasd就爱" size="70" style="height:20px" />
<input type="submit" value="确定提交" style="width:80pxheight:25px">
</form>
php页面
<?php
print_r($_POST[new_title])
?>
获取到的数据是一个数组,如果你不会 *** 作数组再联系我。
$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换你购物车里的内容,应该就可以了
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)