我在发送多个单词值时遇到问题。例如,如果我发送字符串“ 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>

最佳答案

作为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>

关于php - 具有多个单词值的选项标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28890281/

10-12 13:06