数据
<table method="post" name="ppp">
<tr>
<td >
<input type="text" name="abc[]" size="20">
<input type="text" name="def[]" size="20">
</td>
</tr>
</table>
用post提交之后,如果有两条或多条记录如何用foreach循环处理添加到数据表中?
<table method="post" name="ppp">
<tr>
<td >
<input type="text" name="abc[]" size="20">
<input type="text" name="def[]" size="20">
</td>
</tr>
</table>
用post提交之后,如果有两条或多条记录如何用foreach循环处理添加到数据表中?
<tr>
<td >
<input type="text" name="abc[]" size="20">
<input type="text" name="def[]" size="20">
</td>
</tr>
</table>
用post提交之后,如果有两条或多条记录如何用foreach循环处理添加到数据表中? $aaa=$_POST['abc'];
$bbb=$_POST['def']; foreach ($aaa AS $key => $value)
{
foreach ($bbb AS $k => $v)
{
$sql="insert into table.user(name,id) values ('$aaa[key]','$bbb[k]')"
}
}
比方说有两条记录,用这样插入数据库的话就变成了四条,如何实现有几条添加几条
//选中的checkbox才能在处理页面取到这些值(那个被选中了)//处理页面abc为传过来的数组
$abc = $_POST['abc'];
for($i=0;$i<count($abc);$i++)
{
$id=$abc[$i];
$sql="insert into table.user(name,id) values ('')" }
//首先你 <input type="text" name="def[]" size="20"> 这里要加一个value="$id"这样你
//选中的checkbox才能在处理页面取到这些值(那个被选中了) //处理页面abc为传过来的数组
$abc = $_POST['abc'];
for($i=0;$i <count($abc);$i++)
{
$id=$abc[$i];
$sql="insert into table.user(name,id) values ('')" }
插多条数据,insert into table (id ,name) values (NULL,$_GET["what"][0]),(NULL,'$_GET["what"][0]'),...(NULL,$_GET["what"][n])即可
$a=$_POST['abc'];
$b=$_POST['def'];$aaa=count($a); for($i=0;$i <$aaa;$i++)
{
$name1=$a[$i];
$name2=$b[$i];
$sql="insert into table.user(name1,name2) values ('$name1','$name2')" }