Home > Backend Development > PHP Tutorial > php+mysql循环插入数据。。急急急

php+mysql循环插入数据。。急急急

WBOY
Release: 2016-06-23 14:19:11
Original
1638 people have browsed it

PHP MySQL

//现在要取出每个编码对应的数据做插入。。for($i=0;$i<count($bms);$i++){echo $bms[$i]."---------".$sls[$i]."-----".$pro_b."<br>";echo $sql="select * from xxx where 编码='$bms[$i]'";echo "<br>";}//详细说明,上面假如'编码'循环为:101 102 103 104 我要做的事是//$sql="select * from xxx where 编码='101' //然后把编码是101对应的数据取出来做插入//$sql="select * from xxx where 编码='102' //然后把编码是102对应的数据取出来做插入。。。。。//新手求教,不胜感激,不知道我的意思表达清楚了没有,技术有限正在学习中望各位不要骂给点提示,指导
Copy after login


回复讨论(解决方案)

$sql="insert into tt select * from xxx where 编码 in('".join("','",$bms)."')";mysql_query($sql);
Copy after login

谢谢。。我试试

//添加成功

$sqll="insert into cart(bm,mc,lx) select 编码,名称,类型,from xxx where 编码 in('".join("','",$bms)."')"//咋样把那个$sls的值加进去啊
Copy after login

$sls 是什么? 加在哪?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template