<form id="form1" name="form1" method="post" action="updatebodyNo.php">
<table width="356" border="0" align="center">
<tr>
<td width="94"><span class="style12"><span class="style12 style57">BodyNo</span></span></td>
<td width="155"><span class="style12"><span class="style12 style57">Defect Code</span></span></td>
<td width="93"><span class="style12"><span class="style12 style57">Quantity</span></span></td>
</tr>
<tr>
<?php
include ("connection.php");
// get value of id that sent from address bar
$bodyNo=$_GET['bodyNo'];
$sq1 = mysql_query ("SELECT * FROM paintshop WHERE bodyNo = '$bodyNo'") or die ("error");
while($result = mysql_fetch_array($sq1)){
?>
<td><span class="style12 style57">
<input type="text" name="bodyNo[]" id="bodyNo[]" value="<?php echo $result['bodyNo']; ?>"/>
</span></td>
<td><span class="style12"><span class="style12 style57">
<input type="text" name="defect_code[]" id="defect_code[]" value="<?php echo $result['defect_code']; ?>"/>
</span></span></td>
<td><input type="text" name="qty[]" id="qty[]" value="<?php echo $result['qty']; ?>"/></td>
</tr><?php } ?>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" /></td>
<td> </td>
</tr>
</table>
</form>
THEN updatebodyNo.php code
<?php
include("connection.php");
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("paintshop", $con);
$bodyNo = $_POST['bodyNo'];
$defect_code = $_POST['defect_code'];
$qty = $_POST['qty'];
//$EndDate = $_POST['EndDate'];
$limit = count($bodyNo);
for($i=0;$i<$limit;$i++) {
$bodyNo[$i] = mysql_real_escape_string($bodyNo[$i]);
$defect_code[$i] = mysql_real_escape_string($defect_code[$i]);
$qty[$i] = mysql_real_escape_string($qty[$i]);
//$EndDate[$i] = mysql_real_escape_string($EndDate[$i]);
$query = "UPDATE paintshop SET bodyNo='$bodyNo[$i]', defect_code='$defect_code[$i]', qty='$qty[$i]' WHERE bodyNo='$bodyNo[$i]'";
$result = mysql_query($query);
//memaparkan mesej sama ada berjaya atau tidak
if ($query==TRUE)
echo "<script type = 'text/javascript'> alert (' SUCCSESFUL INSERTED!'); </script>";
echo "<script>window.location = 'userView1.php?';</script>";
if ($query==FALSE)
echo "<script type = 'text/javascript'> alert (' ENCOUNTERED AN ERROR!'); </script>";
echo "<script>window.location = 'userView1.php?';</script>";
}
mysql_close($con)
?>
the problem is, when i update, all information become same.