0

Please tell me there is an n-th amount of input. It is always different, maybe 1, maybe 20. The code looks like this:

<form action="/1.php" method="post">
<input type="text" value="1" name="more[1]">
<input type="text" value="2" name="more[2]">
<input type="text" value="3" name="more[3]">
<input type="text" value="4" name="more[4]">
<input type="text" value="5" name="more[5]">
<input type="submit">
</form>

How to add to the database table as many rows as we have input in the form? That is, 5 records should be created in the table. Thank you in advance.

1 Answers1

0

On your Action page Create a loop on your input array

Try this

foreach($_POST['more'] as $value){
   $query = mysqli_query('Insert Into TableName Values("",$value)');
}

Hope this idea will help you

MD. Jubair Mizan
  • 1,539
  • 1
  • 12
  • 20