-1

I have a form with 3 fields iteno, perno, and description with three textboxes in a row(iteno,perno, description). However a user can click a button and dynamically add another row having the same 3 text boxes(iteno,perno, description). He/she can add as many rows as he/she wants with same set of boxes(iteno,perno, description).

My question is how to insert the same to database using php & mysql by using foreach loop.

A J
  • 3,970
  • 14
  • 38
  • 53
EriGits
  • 17
  • 6
  • There's not enough details. Do you insert each yime the user click the button? If so, ajax is the answer. If you submit it somehow, you can do a plain insert of multiple entry with a single mysql request. See this answer for more info: http://stackoverflow.com/questions/6889065/inserting-multiple-rows-in-mysql – Carl Boisvert Oct 17 '15 at 12:55

1 Answers1

0

If you examine the form post you will, I guess, see only one value for each textbox. To submit multiple rows from a single form, you need to define each textbox as an array, then multiple rows will be posted.

<input type="text" name="iteno[]" />

Now when you process it each post param will be an array that you iterate over.

A J
  • 3,970
  • 14
  • 38
  • 53
David Soussan
  • 2,698
  • 1
  • 16
  • 19