带有多个单词值的选项标签

时间:2015-03-06 00:14:11

标签: php html mysql

我在使用post发送多个单词值时遇到问题。例如,如果我发送字符串“Jazz and Blues”,它只发送“Jazz”。你知道问题出在哪里吗?谢谢你的帮助。

<select name="zaner" required>

    <option value=""></option>
    <?php
    $z = array("Elektro", "Drum and Bass", "Hardcore", "House", "Techno", "Trance", "Dubstep", "Folk", "Pop", "Jazz and Blues", "Reggae", "RnB", "Rap", "Metal", "Punk", "Clasic", "Alternative", "Indie", "Rock", "Country", "Disco", "Funky", "Experimental", "Soul and ghospe");
    foreach ($z as $zaner) {                        
        echo "<option value=" .$zaner. ">" .$zaner. "</option>";
    }
?>
</select>

1 个答案:

答案 0 :(得分:0)

作为N.B.提到,您忘记在选择标记中指定multiple="multiple",即

<select name="zaner[]" multiple="multiple" required>
    <option value=""></option>
<?php
$z = array("Elektro", "Drum and Bass", "Hardcore", "House", "Techno", "Trance", "Dubstep", "Folk", "Pop", "Jazz and Blues", "Reggae", "RnB", "Rap", "Metal", "Punk", "Clasic", "Alternative", "Indie", "Rock", "Country", "Disco", "Funky", "Experimental", "Soul and ghospe");
foreach ($z as $zaner) {                        
    echo "<option value=" .$zaner. ">" .$zaner. "</option>";
}
?>
</select>