hi im a beginner on php and i just want to know if my codes is correct because when i try to update it it only saves the last value i hope some one can understand me.
$id = ($_REQUEST['StudentNumber']);
$result= mysql_query("SELECT NameofSiblings, Age, HEA, CivilStatus, Occupation FROM $tblname where StudentNumber='$id'");
$child = $_REQUEST['NumberofChildren'];
echo "<form method='post' >";
for($n=1; $n<=$child; $n++)
{
while($row=mysql_fetch_array($result))
{
echo "<table>
<tr>
<td class='siblings'><input type='text' name='sibname[]' style='width: 150px;' value=".$row['NameofSiblings']."></td>
<td class='siblings'><input type='text' name='sibage[]' style='width: 35px;' value=".$row['Age']."></td>
<td class='siblings'><input type='text' name='sibhea[]' style='width: 260px;' value=".$row['HEA']."></td>
<td class='siblings'><input type='text' name='sibcs[]' style='width: 100px;' value=".$row['CivilStatus']."></td>
<td class='siblings'><input type='text' name='siboccu[]' style='width: 100px;' value=".$row['Occupation']."></td>
</tr>
</table>";
}
}
<td><input type="hidden" name="n" value="<?php echo $child; ?>">
and this is my separate php for update
$n=intval($_POST['n']);
for($i=0;$i<$n;$i++)
{
$sibname =$_POST['sibname'][$i];
$sibage =$_POST['sibage'][$i];
$sibhea =$_POST['sibhea'][$i];
$sibcs =$_POST['sibcs'][$i];
$siboccu =$_POST['siboccu'][$i];*/
$query = "UPDATE $tblname SET NameofSiblings = '$sibname', Age = '$sibage', HEA = '$sibhea', CivilStatus = '$sibcs', Occupation = '$siboccu' WHERE StudentNumber='$sn' ";
mysql_query($query);
}