需要用到,简单是思路,记录一下。不过用到的应该不多。。。
一般会循环列出表记录到表单里
<?php
$que=mysql_query("select * from test order by id ");
while($rs1=mysql_fetch_array($que))
{
?>
<input type="text" value="<?php echo $rs1['title'] ?>" name="title[]" size="2">
<input type="hidden" value="<?php echo $rs1['id'] ?>" name="id[]" size="2">
<?php
}
?>
$que=mysql_query("select * from test order by id ");
while($rs1=mysql_fetch_array($que))
{
?>
<input type="text" value="<?php echo $rs1['title'] ?>" name="title[]" size="2">
<input type="hidden" value="<?php echo $rs1['id'] ?>" name="id[]" size="2">
<?php
}
?>
处理程序,搞个循环
$id=$_POST['id'];
$title=$_POST['title'];
if($num=count($id))
{
for($i=0;$i<$num;$i++)
{
$q=mysql_query("update test set title='".$title[$i]."' where id='".$id[$i]."'");
}
}
$title=$_POST['title'];
if($num=count($id))
{
for($i=0;$i<$num;$i++)
{
$q=mysql_query("update test set title='".$title[$i]."' where id='".$id[$i]."'");
}
}
搞定,但是不知效率如何。明天测试效果。。。
思路对啦。
在这个基础上稍做变化,将数组转为字符串,就可以不用循环来执行。条件改用where_in执行,效率应该还可以。