[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

multiple mysql insert queries based on number of forms submitted

The URL posted is a form I made. Pick any number and it will show you another form. When the continue is clicked, javascript will check if the form is complete, then forward to a confirmation page. There will be another continue button which will "confirm" the page and dump all the info into 2 different tables on a database. The first box posts to table1, and the remaining info posts to table2. The problem is, the remaining info fields are dynamically generated (depending on how many people you pick, it duplicates the box that many times.), so how can I create a php scrpt that will post all the info completed to the database?
2 Solutions
in php you can do a little trick with the names of your form fields...

firstName[]  as a name for all the first names, and lastName[] for all the last name fields...

in php when the data is received with the register globals on it will create arrays $firstName and $lastName.

so you could do $firstName[0], $firstName[1],

another option is an iterator variable in your php... tell the php how many inputs there are and out put them like this...

firstName1, firstName2.. then in the php loop through the iterator value like $_GET["firstName".$x]

I don't know if that was the question or if you need to know basic database inserts too...
One other problem with your script is: using the IE way to get reference to an element: ratna in the checkData function. Using document.getElementById("ratna"); instead, so your code will work well in other browser too. Or because you are using checkData as onChange handler, just uses 'this' keyword to refer to attendee selection box
chronus72488Author Commented:
Thanks Isisagate, that was the exact answer I needed.

Also thanks to KhoiNgg, that jsp error as my next question but you already answered it for me.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now