0
我尝试以html格式获取多个选择值。在PHP中获取多个选择值
我在我的'名称'属性中添加括号,但它仍然不起作用。
我用写的过程中“框架”,有充分为例:https://github.com/bpesquet/MonBlog/
形式
<form method="post" action="index.php?controleur=Creer&action=addFilm" style="display:none" id="addFilm">
<label>Title</label>
<input type="text" name="title" required> <br>
<label>Release date</label>
<input type="date" name="release" required> <br>
<label>Synopsis</label>
<textarea name="synopsis"></textarea> <br>
<label>Nationality</label>
<select name="nationality[]" multiple>
<?php foreach($pays as $payss): ?>
<option><?= $payss['nom_pays'] ?></option>
<?php endforeach ?>
</select> <br>
<label>Genre</label>
<select name="genre[]" multiple>
<?php foreach($genres as $genre): ?>
<option><?= $genre['nom_genre'] ?></option>
<?php endforeach ?>
</select> <br>
<label>File name</label>
<input type="text" name="filename" required> <br>
<input type="submit" value="Submit">
</form>
我填写选择元素从数据库PHP。
我的$ _ POST变量是
Array ([title] => test_film [release] => 2000-11-20 [synopsis] => [nationality] => USA [genre] => Comedy [filename] => test)
(仅最后一个元素被选择为一个字符串)
当我看到在我的导航请求我有正确的POST参数 它看起来像这样:
title: "test_film"
release: "2000-11-11"
synopsis: ""
nationality: [2]
[0]: "USA"
[1]: "France"
genre: [2]
[0]: "Thriller"
[1]: "Comedy"
filename: "test"
但变量'genre'不是$ _POST中的数组
制作的print_r($ _ POST),并告诉我们。 –
尝试添加'value'属性到您的选项标签 – hungneox
我真的不'不明白。 我添加'价值'财产昨天@noctilux说,它的作品。 我今天删除它,它仍然有效... – laRob