ezgoing Posted September 28, 2012 Share Posted September 28, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268866-using-the-same-table-twice-with-_post/ Share on other sites More sharing options...
DavidAM Posted September 28, 2012 Share Posted September 28, 2012 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]; Quote Link to comment https://forums.phpfreaks.com/topic/268866-using-the-same-table-twice-with-_post/#findComment-1381459 Share on other sites More sharing options...
Christian F. Posted September 28, 2012 Share Posted September 28, 2012 Also, please use the [code][/code] tags around your code, as it helps make both your post and your code a lot easier to read. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/268866-using-the-same-table-twice-with-_post/#findComment-1381466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.