我正在尝试将用户选择从多选表单捕获到PHP中,这样我就可以根据需要匹配用户选择。以下是HTML:
<tr>
<!-- <label for="DutiesDesc">Duties Description: </label><textarea name="DutiesDesc" cols="30" rows="5" /></textarea>-->
<td><label for="DutiesDesc">Job Attributes:</label></td>
<td><select name="DutiesDesc[]" size="<?php $items ?>" multiple="multiple">
<?php while($row = mysql_fetch_array($attribid))
{ ?>
<option value="<?php echo $row['AttribName']?>"><?php echo $row['AttribName']?></option>
<?php }?>
</select></td>
</tr>
选项显示正确,以下部分是我获取用户输入并将其存储在数组中供以后使用的地方。另请注意,显示的多选框选项是从MySQL数据库中检索的。
//Array to store user input from the multiselect box
$SkillsArray = $_POST['DutiesDesc'];
//Count the number of items in the array
$counter = count($SkillsArray);
仅出于测试目的,我计算数组中的项目数并将其显示为:
echo $counter;
但是我收到以下错误:
注意:未定义的索引:在$ counter上。
我认为这可能意味着$skillsarray
没有任何值,或者用户选择的选项没有保存到变量中。请协助。