Add various form data to database with mysql, php, and jquery

Discussion in 'Programming' started by danramosd, Mar 9, 2010.

  1. #1
    What i'm doing is kind of complicated to explain but Ill do my best. I have about 10 different forms, some that share the same questions and some that dont. They are all radio buttons. So far i am able to validate (make sure each question is answered) and get the value of all the questions. What i want to do is take all the values from the form and send it to a PHP script which will then add it to the database. I was wondering if there was a way that I could write a PHP script that loops through all the variables present passed from the javascript(jquery to be exact) and insert it into the database. I know I could check for each variable individually and create an sql INSERT string for each one but that would be too cumbersome when i go to add more forms.

    Along with that, when i go to send the variables from jquery(using ajax) to php should i put them in a regular array or a JSON object. If its a json object how do i go about populating for the object?
     
    danramosd, Mar 9, 2010 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    I suggest serializing the array and insert it into one simple field then when you need the infos just unserialize
     
    crivion, Mar 10, 2010 IP