I'm trying to Update multiple rows at once in mysql w/ 1 form- I'm working with this demo...
http://www.phpeasystep.com/mysql/10.html
I created the DB & table ok (part 1 - Create table "test_mysql")
then i did part 2 - Create file - update_multiple.php
- i lists the 6 people ok - and I edit some of the fields - EXPECTING IT TO UPDATE THEM when I press update - But it DOES NOT and just replaces with original data.
here is the form post code...
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td>
<td align="center"><input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>"></td>
<td align="center"><input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>"></td>
</tr>
<?php
}
?>
here is the update code...
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}
Q: How do I get it to update correctly?