Selects in PHP
Let's now learn how to work with the
select
tag in PHP. Let's make such a dropdown list in
our form:
<form action="" method="GET">
<select name="test">
<option>item1</option>
<option>item2</option>
<option>item3</option>
</select>
<input type="submit">
</form>
After submitting the form, $_GET
of the select
will contain the value of the selected
option
tag:
<?php
var_dump($_GET['test']); // 'item1', 'item2' or 'item3'
?>
Using a dropdown list, suggest the user select the country they live in.