0

I'd like to serialzie multiple rows in my table using serialize() to update my database. The form data looks like this:

f_name=tom&l_name=riddle=&f_name=albus&l_name=dumbledore

If I send this data to php with $.post('file.php', formData, function(result) and log the returned result I can only see the last entry (f_name=albus&l_name=dumbledore). How can I send multiple rows with the same input fields to the php file?

Mr. Potter
  • 85
  • 7
  • 1
    There are too many tags with no supportive code. – Funk Forty Niner May 22 '20 at 21:52
  • Does this answer your question? [Multiple inputs with same name through POST in php](https://stackoverflow.com/questions/7880619/multiple-inputs-with-same-name-through-post-in-php) – gre_gor May 22 '20 at 22:11

1 Answers1

1

Give your inputs array-style names:

<input name="f_name[]" type="text">
<input name="l_name[]" type="text">

Then the correspoding $_POST variables will be arrays, with an element for each row. The form data will look like

f_name[]=tom&l_name[]=riddle=&f_name[]=albus&l_name[]=dumbledore
Barmar
  • 741,623
  • 53
  • 500
  • 612