In php I have a form like this
<form action="" method="post">
<table id="user-data">
<tr>
<td>Firstname</td>
<td>Lastname</td>
<td>Age</td>
</tr>
<tr>
<td><input type="text" name="firstname[]"></td>
<td><input type="text" name="lastname[]"></td>
<td><input type="text" name="age[]"></td>
</tr>
<tr>
<td><input type="text" name="firstname[]"></td>
<td><input type="text" name="lastname[]"></td>
<td><input type="text" name="age[]"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
Now I want to insert the data into mysql table. For that my script is like this so far now
<?php
$host = 'localhost';
$uname = 'root';
$pwd = 'root';
$db = 'Test';
$con=mysqli_connect($host,$uname,$pwd,$db);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$age = $_POST['age'];
echo '<pre>';
print_r($firstname);
print_r($lastname);
print_r($age);
echo '</pre>';
?>
Now from here I want to know how to insert the values into database within the array. Any help and suggestions will be really apprecaible. Thanks