Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:02:10+00:00 2026-06-11T04:02:10+00:00

I have a html form where i append few elements like, when user select

  • 0

I have a html form where i append few elements like, when user select multiple countries from list jquery run through the selected lists and create a set of form fields for each country.

Assume user selected USA, China and India, then form fields will be created for each of this countries giving id asn name as *countryName_indexValue, customeName_countryName_indexValue.*

My question:
I need to submit this appended elements values to mysql database through php when user fill and hits submit button. How do i do it? Please help me……

And the result is this

<form>

<table>
<thead>
<tr>
<td>Country Name</td>
<td>Data01</td>
<td>Data02</td>
</tr>
</thead>

<!-- APPENDED ELEMENTS -->

<tbody>
<tr id="usa_0">
<td><input type="text" name="userCountry_usa_0" id="userCountry_usa_0"></td>
<td><input type="text" name="countryData01_usa_0" id="countryData01_usa_0"></td>
<td><input type="text" name="countryData02_usa_0" id="countryData02_usa_0"></td>
</tr>

<tr id="china_1">
<td><input type="text" name="userCountry_china_1" id="userCountry_china_1"></td>
<td><input type="text" name="countryData01_china_1" id="countryData01_china_1"></td>
<td><input type="text" name="countryData02_china_1" id="countryData02_china_1"></td>
</tr>

<tr id="india_2">
<td><input type="text" name="userCountry_india_2" id="userCountry_india_2"></td>
<td><input type="text" name="countryData01_india_2" id="countryData01_india_2"></td>
<td><input type="text" name="countryData02_india_2" id="countryData02_india_2"></td>
</tr>
</tbody>

</table>

</form>

Thank you..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:02:11+00:00Added an answer on June 11, 2026 at 4:02 am

    So what’s the issue? Are you running into issues when you submit the data? Or are you struggling to handle the $_POST on the PHP side?

    If it’s handling the $_POST, I’d suggest changing your generated form fields to have ids of the form userCountry[countryName][indexValue] instead of userCountry_countryName_indexValue.

    That way, when the form is submitted, the $_POST will consist of arrays, which you can then loop over to write to a DB, e.g. the $_POST would have something like:

    $_POST['userCountry'] = array( 'usa' => array( '0' => 'someValue'),
                                   'china' => array( '1' => 'someOtherValue'),
                                   'india' => array( '2' => 'yetAnotherValue'),
                            )
    

    Then you can loop over this, e.g.:

    foreach($_POST['userCountry'] as $country=>$subArray) {
        //code here to insert data
    }
    

    Your current implementation could work with loops as well, as long as you loop over the whole $_POST object, checking each key, and looking for particular sub-strings, exploding on underscores, and then handling, but it’d be kind of ugly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have select inputs dynamically added to form by $(selector).append(html) I'm using live('change',handler) to
I have a HTML form that accepts a comma separated list of tags, which
I have an HTML form which, when submitted by the user, will call a
I have a form that generates sortable divs. I am using .append() and .html()
I have tried to append <option> inside <select> using javascript by parsing data from
I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I'm building a web page form with jquery append() , html() etc and I'm
I have a few areas in a form I'm producing where I use jquery
I have an HTML form that a user can add an arbitrary amount of
I have an html form where on the input field selection from a drop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.