I am trying to create a html/php form that allows an array of data to be displayed in a drop/selection menu. How would i turn this into one?
<?php
$OptionID = 1;
foreach( $this->setRoleOptions as $RoleID => $RoleName ) :
echo '<div align="center">';
echo '<input type="checkbox" style="width: 30px;" name="RoleID" value="'. $RoleID .'" ';
if ( $OptionID == 1 ) :
echo ' CHECKED ';
endif;
echo '/> '. $RoleName;
echo '</div>';
++$OptionID;
endforeach;
?>
I have tried the below code which gets the array but once the option is selected, nothing happens.
<?php
$OptionID = array("Administrative", "Operations 1", "Operations 2");
?>
<select>
<?php foreach ($this->setRoleOptions as $RoleID => $RoleName): ?>
<option name="RoleID" value="<?php echo $RoleID; ?>"<?php if ($row['RoleID'] == $OptionID): ?> selected="selected"<?php endif; ?>>
<?php echo $RoleName;?>
</option>
<?php endforeach; ?>
</select>