multiple mysql insert queries based on number of forms submitted

Posted on 2007-10-16
Last Modified: 2013-12-13
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?
Question by:chronus72488
    LVL 11

    Accepted Solution

    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...
    LVL 3

    Assisted Solution

    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

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to dynamically set the form action using jQuery.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now