我有一个下拉菜单,我想将其更改为多选框。如果您只选择 1 个选项(我之前的方式),下面的代码就可以工作,但是您选择 2 它只会显示两个选项中的 1 个,我怎样才能让它显示两个选项都被选中,这里是代码:
<?php $makes = array("volvo","Saab","Opel","Audi","BMW") ?>
<form method="post" name="store" action="<?php $_SERVER['PHP_SELF'] ?>" >
<select multiple="multiple" name="cars">
<?php foreach ($makes as $make){echo "<option value=\"$make\">". $make ."</option>"; $vehicles = $_POST['cars'];} ?>
<input name="submit" type="submit">
</select>
</form>
<?php
if($_POST['submit']){
echo $vehicles;
}
?>
</body>
</html>