清风徐来
知是行之始,行是知之成

PHP数据记录批量更新代码

PHP 批量更新 约 1 分钟

需要用到,简单是思路,记录一下。不过用到的应该不多。。。 一般会循环列出表记录到表单里

<?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]."'"); 
   } 
}

搞定,但是不知效率如何。明天测试效果。。。