I'm trying to build a directory that holds members in a family. I can build the form that has the user enter a number and then it echos out a form for them to enter each members information, but I don't know how to enter all that information into the database.
Heres my PHP code.
<?php
if($_POST['submit2']) {
$number = $_POST['number'];
echo "<table border=\"1\">\n";
for($i = 1; $i <= $number; $i++) {
echo "this is where I'm stuck!<br><br>";
}
echo "</table>\n";
}
if($_POST['submit']) {
$number = $_POST['number'];
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"number\" value=\"" . $number . "\">";
echo "<table border=\"1\">\n";
echo "<th>#</th>\n<th>Firstname</th>\n<th>Age</th>\n<th>Birthday</th>";
for($i = 1; $i <= $number; $i++) {
?>
<tr>
<td><?=$i;?></td>
<td><input type="text" name="name-<?=$i;?>"></td>
<td><input type="text" name="age-<?=$i;?>"></td>
<td><input type="text" name="birthday-<?=$i;?>"></td>
</tr>
<?php
}
echo "<input type=\"submit\" name=\"submit2\">\n";
echo "</table>\n</form>";
}else {
?>
<form method="POST">
Enter a number <input type="text" name="number"> <input type="submit" name="submit">
</form>
<?php
}
?>
To make it easier for everyone that looks at this I've included an image of what my database looks like.