I'm trying to make a dropdown list that allows users to select a training program that matches their needs, so when they select it, the option will go into a table in the MySQL database.
This is my HTML form:
<form action="sessionreq.php" method="POST">
<div class="form-group">
<label for="exampleSelect1">Category</label>
<select class="form-control" id="exampleSelect1">
<option name='eg1'>Example option</option>
<option name='eg2'>Example option 2</option>
<option name='eg3'>Example option 3</option>
</select>
</div>
<button type="submit" class="button button-block" name="delete">Request</button>
<br>
</form>
What I need is an SQL query that will go with it, so when they select 'Example option 3', it will be entered into the database in a column called method
. I should be inserted into method
with the values (depending on their option in the dropdown). For example, if the user selected Example option 2
it would be inserted into method
with the values Example option 2
.
How do I populate database tables/columns with dropdowns?