将多个选择选项存储到PHP数组中 [英] store multiple select option into a PHP array

查看:90
本文介绍了将多个选择选项存储到PHP数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择框列表是否可以选择多个选项:

I have an selectbox list Is it possible to select multiple option:

<select name="access_list[ ]" size="7" multiple="multiple">
<?php $res=mysql_query("select * from list" ,$conn);
while($row=mysql_fetch_assoc($res))
echo"<option value=".$row['id'].">".$row['name']."</option>";?>
</select>


如何将要选择的值(一起选择多个值)存储在数组中.我认为每个订单都可以做到吗?


How do the values ​​that will be selected (select multiple values ​​together) can be stored in the array. I think that will do it for each order?

推荐答案

将名称用作name="access_list[]",不带空格.

Use name as name="access_list[]" without space.

您可以使用$_POST['access_list']

$_POST['access_list']array,其中包含选定的选项

$_POST['access_list'] is array that contains selected options

这篇关于将多个选择选项存储到PHP数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆