I have a <select>
with multiple allowed choices at the same time. I want to keep ALL selected values after a form submission. How to do this?
I tried the followig, but this only works for ONE option...
<select multiple name="example" method="POST" action="<? echo $_SERVER['PHP_SELF']?>">
<option value="optA" <?php if ($_POST['example'] === "optA"){echo 'selected="selected"';} ?>>Option A</option>
<option value="optB" <?php if ($_POST['example'] === "optB"){echo 'selected="selected"';} ?>>Option B</option>
</select>
Expectedly the following always returns the latest selected option:
<?php if (isset($_POST['example'])){echo $_POST["example"];} ?>
So how can i achieve my goal? Many thx in advance! :)