Jump to content

[SOLVED] Accessing dynamically created HTML forms


amjohnno

Recommended Posts

There is probably an extremely simple answer to this but I can't seem to get my head around it.

 

Basically I have a form dynamically created by results from a database. As such it's going to be different ever time it's used. For each row in the database I want to have a drop-down list. So my HTML form looks like this:

 

<form id="formid" name="formname" method="POST" action="page.php">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Text 1</td>
<td>Text 2</td>
<td>
<select name="reference_to_unique_database_id">
  <option value="7" selected="selected">Seven</option>
  <option value="6">Six</option>
  <option value="5">Five</option>
  <option value="4">Four</option>
  <option value="3">Three</option>
  <option value="2">Two</option>
  <option value="1">One</option>
</select>
</td>
</tr>

<tr>
<td>Text 1</td>
<td>Text 2</td>
<td>
<select name="reference_to_unique_database_id">
  <option value="7" selected="selected">Seven</option>
  <option value="6">Six</option>
  <option value="5">Five</option>
  <option value="4">Four</option>
  <option value="3">Three</option>
  <option value="2">Two</option>
  <option value="1">One</option>
</select>
</td>
</tr>

[etc...]

<tr>
<td colspan="3"><input type="submit" value="Update" /></td>
</tr>
</table>
</form>

 

My question is, once I've submitted the form how would I gather the information using php given that each time the form is submitted the names of the form elements are going to be different?

Link to comment
Share on other sites

If im getting your question right then the answer is simple. All the dynamically created post keys and values may be accessed by the $_POST superglobal. U can use print_r($_POST) to print out all the keys and their specific values.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.