Jump to content

Recommended Posts

New at PHP and I have feeling this is an easy fix.

 

 

echo "<select id='mainselection' name = Preparations>";

$query = 'SELECT Preparations FROM test.preparation';

$result5 = mysql_query($query, $cxn )

or die ("I think there's a problem Dude.");

while ($_POST = mysql_fetch_array($result5)) {

extract ($_POST);

echo "<option value='$_POST[Preparations]'>$_POST[Preparations]\n";

}

echo "</select>";

echo "<td><select id='mainselection' name = Preparations>";

$query = 'SELECT Preparations FROM test.preparation';

$result6 = mysql_query($query, $cxn )

or die ("I think there's a problem Dude.");

while ($_POST = mysql_fetch_array($result6)) {

extract ($_POST);

echo "<option value='$_POST[Preparations]'>$_POST[Preparations]\n";

}

 

I have two dropdowns menus using the same table and when dropdown 1 selects an option and dropdown 2 has another option selected only the value for the first dropdown is passed. I'm thinking I need to pass the &_POST value for the second dropdown to a new &_POST var but dont know how or if that's correct. Hope that makes sense.

Link to comment
https://forums.phpfreaks.com/topic/268866-using-the-same-table-twice-with-_post/
Share on other sites

Since you gave both fields the same name, one is overwritting the other. You can use a different name or post them as an array. By the way, the name should be in quotes (just like you did for the id).

 

To post to an array change them both to: <select id='mainselection' name='Preparations[]'> --- notice the empty square-brackets at the end of the name. You can then reference the fields separately as $_POST['Preparations'][0]; and $_POST['Preparations'][1];

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.