Home >Backend Development >PHP Tutorial >php-HTML多选控件提交的表单数据在PHP里如何显示 ?

php-HTML多选控件提交的表单数据在PHP里如何显示 ?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-02 11:29:381115browse

php表单html

如下一段HTML表单,提交到recv.php显示:

<code><form action="recv.php">    UserName:    <input type="text" name="username"><br>    Sex:    <input type="radio" name="sex" value="male" checked>Male    <input type="radio" name="sex" value="female">Female<br>    Profession:    <select name="profession">        <option value="student">Student</option>        <option value="teacher">Teacher</option>        <option value="worker">Worker</option>    </select><br>    Favourite:    <input type="checkbox" name="favourite" value="basketball" checked>Basketball    <input type="checkbox" name="favourite" value="volleyball">Volleyball    <input type="checkbox" name="favourite" value="football">Football<br>    <input type="submit" value="Submit">
</form> </code>

recv.php代码如下:

<code> <?php echo '<pre class="brush:php;toolbar:false">';     print_r($_GET);     echo '</code>
'; ?>

1、为何获取到的多选项,如favourite,即使选了多个,在php里也只能显示一个,这是为什么?如何才能全部显示出来?
2、如果在select里加入multiple="multiple",那么这个下拉列表就不再在一行显示,而是全部显示出来,这是怎么回事?我不就是想要变成多选而已吗?如何处理呢?

谢谢!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn