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.

2
  • I can't find the php code anywhere! Did you perhaps forget to paste it? Commented Jan 29, 2019 at 15:24
  • check the $_POST array Commented Jan 29, 2019 at 15:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

use the mysqli_close($conn); and header() Outside of the loop

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.