Before anyone flames, I have looked at many more than just the following 3 posts. None of these have working answers.
How to Post data from a php database populated Drop Down to another script?
Passing value from a dropdown list from one php to another
What is the best way to have a dynamic dropdownlist in PHP and POST selected value
These simply just do. not. work.
Now on to my question:
I have a dropdown list on my php page that is being populated by a MySQL query. This part works perfectly. However -- I can not get the selected value from the dropdown list to post in to my next PHP script.
My code on "page1.php":
Please select your dietary preference:
<form method="post" action="page2.php">
<tr>
<td>
<select name="dropdown_value">
<?php foreach ($data as $row): ?>
<option><?=$row["dietary_option"]?></option>
<?php endforeach ?>
</select>
</td>
</tr>
</form>
This successfully populates my dropdown list with the available dietary options pulled from my database.
And on page2.php:
$mealSelection = $_POST["dropdown_value"];
Simply does nothing. It yields no value(?). Echoing $mealSelection seemingly echoes nothing. It is blank.
I would ultimately like to use $mealSelection in a new query on page2.php but I can't seem to retrieve the selected value from page1.
Any wizards with some insight?
Thanks for taking the time to look at my issue here.
LC-Data
Edit: None of the answers for simply posting dropdown options from predefined HTML work. I specifically need the dropdown to be populated from my db.