i'm a beginner on php and i'm trying to save this loop to a database but it only saves the last row on the database..i hope someone can answer this thanks in advance.
<?php
$child = $_REQUEST['NumberofChildren'];//requested from the lastpage
echo "<form method='post' action='familysave.php'>";
for($n=1; $n<=$child; $n++)
{
echo "<table>
<tr>
<td><input type='text' name='sibname' placeholder='Fullname' style='width: 150px;' required></td>
<td><input type='text' name='sibage' placeholder='Age' style='width: 35px;' required></td>
<td><input type='text' name='sibhea' placeholder='Highest Educational Attainment' style='width: 260px;'></td>
<td><input type='text' name='sibcs' placeholder='Civil Status' style='width: 100px;' required></td>
<td><input type='text' name='siboccu' placeholder='Occupation' style='width: 100px;' required></td>
</tr>
</table>";
}
?>
<input type="submit" value="Save">
<?php echo "</form>";
?>
this is the code of familysave.php
<?php
$conn = mysql_connect($host, $username, $password);
if(! $conn)
{
die('Could not connect: ' . mysql_error());
}
$sibname =$_POST['sibname']
$sibage =$_POST['sibage']
$sibhea =$_POST['sibhea']
$sibcs =$_POST['sibcs']
$siboccu =$_POST['siboccu']
$sql = "INSERT INTO $tblname (NameofSiblings, Age, HEA, CivilStatus, Occupation) VALUES ('$sibname', '$sibage', '$sibhea', '$sibcs', '$siboccu')";
mysql_select_db($dbname);
$retval = mysql_query($sql, $conn);
if(! $retval)
{
die('Could not Enter Data:' . mysql_error());
}
mysql_close($conn);
?>