select Posted December 2, 2009 Share Posted December 2, 2009 Hi, I am pretty new to these drop down menus and this is pretty much a example I followed. I need to some how get the selected or ($row['bmodel']) put in a session, so I can echo on another page. $_SESSION['sel'] = $row['bmodel']; dbConnect(); $query = "SELECT bid, bmodel FROM cars"; $result = mysql_query($query); $car_menu = ''; $car_menu .= "<option value=\"0\">" . "Choose cars..." . "</option>\n"; while ($row = mysql_fetch_assoc($result)) { $selected = ($row['bid'] == $_POST['cars']) ? ' selected="selected"': ''; $car_menu .= "<option value=\"{$row['bid']}\"{$selected}>". ($row['bmodel']) ."</option>\n"; } <select name="cars" id="cars"> <?php echo $car_menu; ?> </select> Link to comment https://forums.phpfreaks.com/topic/183714-drop-down-menu-get-selected-put-into-session/ Share on other sites More sharing options...
Kieran Menor Posted December 2, 2009 Share Posted December 2, 2009 I suppose you would either submit the field with a form or use AJAX. Link to comment https://forums.phpfreaks.com/topic/183714-drop-down-menu-get-selected-put-into-session/#findComment-969645 Share on other sites More sharing options...
select Posted December 2, 2009 Author Share Posted December 2, 2009 I used the value it worked but i am not too sure it's pretty. $query = "SELECT bmodel FROM cars WHERE bid = {$_SESSION['cars']}"; Link to comment https://forums.phpfreaks.com/topic/183714-drop-down-menu-get-selected-put-into-session/#findComment-969681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.