I'm trying to print multiple values user has selected on form submit. However with following what I'm seeing is only the last element printed irrespective whether it is selected or not.
Note that the print on the screen I'm looking at is a print that a layman can understand!
<?php
if(isset($_POST['submit'])) {
//I'm trying to show the user these are the values you've selected
print_r($option['name']);
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>">
<td class="container">
<select multiple name="mercha_A[]" class="selectpicker form-control" title="Merchandiser type">
<?php foreach ($options as $option) { ?>
<option value="<?php echo $option['value']; ?>" <?php echo (isset($_POST[ 'mercha_A']) && in_array($option[ 'value'], $_POST[ 'mercha_A'])) ? ' selected="selected"' : ''; ?>>
<?php echo $option['name']; ?>
</option>
<?php } ?>
</select>
</td>
<td><button type="submit" name="submit">Submit</button></td>
</form>
Anyone needs a coffee on my account?