Skip to main content
January 21, 2010
Question

Select Multiple into array for data insertion

  • January 21, 2010
  • 1 reply
  • 342 views

I have a form that contains a menu/list that allows multiple selections. The list is bound to a dynamic source with label = to a name and value = to the names record ID. The code DW CS4 generates is:

<select name="vVol_id" size="20" multiple="MULTIPLE" id="vVol_id">
<?php
do { ?>
                <option value="<?php echo $row_rsGetStaff['vol_id']?>"><?php echo $row_rsGetStaff['full_name']?></option>
                <?php
} while ($row_rsGetStaff = mysql_fetch_assoc($rsGetStaff));
  $rows = mysql_num_rows($rsGetStaff);
  if($rows > 0) {
      mysql_data_seek($rsGetStaff, 0);
      $row_rsGetStaff = mysql_fetch_assoc($rsGetStaff);
  }
?>
</select>

What additional code do I need to get the selected items into an array that can be 'foreach'd' to insert the selections into another table when the submit button is clicked? This one has been driving me nuts.

This topic has been closed for replies.

1 reply

Inspiring
January 21, 2010

You just need the square brackets, something like: <select name="vVol_id[]"

vVol_id will then be an array if items are selected.

Ed