Jump to content

Using The Same Table Twice With &_Post


ezgoing

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];

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.