Jump to content

drop down menu, get selected put into session


select

Recommended Posts

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>

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.