Jump to content

Getting the post data from a form in many rows???


bri0987

Recommended Posts

Here is what my form looks like:

 

<form name="form1" method="post" action="testing.php">
          <?php if (isset($_GET['Component_ID'])) {
  $Component_ID = (get_magic_quotes_gpc()) ? $_GET['Component_ID'] : addslashes($_GET['Component_ID']);
} ?>
     <input type="hidden" name="Component_ID" value="<?php if (isset($Component_ID)) { echo $Component_ID; }?>" />
    <p>
      <?php // 4. Use database retured data

while ($row = mysql_fetch_array($db_result1)) {
echo "<input type=\"checkbox\" name=\"Product_ID\" " . "value=\"" . $row["Product_ID"] . "\" />" . " " . $row["Product_Name"] . " <br />" ;
}
?>

    </p>
    <p>
      <input type="submit" value="Submit" />
    </p><?php if (isset($Component_ID)) { echo $Component_ID; }?>
  </form>

 

When I check all of the boxes and I submit this form the data it returns on the testing page is:

 

Component_ID=1&Product_ID=1&Product_ID=2&Product_ID=3&Product_ID=4

 

How do I take that post/get string. Turn it in an array or something and insert it into the database like this:

Component_ID=1 > Product_ID=1

Component_ID=1 > Product_ID=2

Component_ID=1 > Product_ID=3

Component_ID=1 > Product_ID=4

 

 

I am trying to build a relational table between my products and the components...

 

I just do not get how I can do this.

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.