Subash Subash - 1 year ago 70
PHP Question

Get the Selected value from the Drop down box in PHP

I am populating a Drop Down Box using the following code.

<select id="select_catalog">
$array_all_catalogs = $db->get_all_catalogs();
foreach($array_all_catalogs as $array_catalog){?>
<option value="<?= $array_catalog['catalog_key'] ?>"><?= array_catalog['catalog_name'] ?></option>

Now how can I get the selected option value using
(I have the code to get the selected item using
) because I want the selected value to perform a query in database.

Any help will be much appreciated. Thank you very much...

Answer Source

You need to set a name on the <select> tag like so:

<select name="select_catalog" id="select_catalog">

You can get it in php with this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download