我无法在表单提交中保留选定的值(多选)。你看到了问题吗?
<select name='colors[]' id="colors" class="selectpicker" multiple>
<option value='<?php echo $row['table_name']; ?>'>
<?php if(isset($_POST['colors'])) {echo implode(',', $_POST['colors'])} else {echo $row['table_name']} ?>
</option>
</select>
答案 0 :(得分:0)
如果在$_POST['colors']
中你有颜色数组,那么:
<select name='colors[]' id="colors" class="selectpicker" multiple>
<?php
foreach ($_POST['colors'] as $color {
echo "<option>{$color}</option>";
}
?>
</option>
</select>