I'm trying to capture user choices from a multi-select form into PHP so I can match the user choices with what is required. The following is the 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>
The options display correctly, the following part is where I take the user input and store it in an array for later use. Also please note that the displayed multi-select box option are retrieved from a MySQL database.
//Array to store user input from the multiselect box
$SkillsArray = $_POST['DutiesDesc'];
//Count the number of items in the array
$counter = count($SkillsArray);
Just for testing purposes, I count the number of items in the Array and display them as:
echo $counter;
But I get the following error:
Notice: Undefined index: on $counter.
I think this may mean that the $skillsarray
doesn't have any values or user selected options didn't save into the variables. Please assist.