I have a dropdown list which should be displaying the correct value of the record retrieved from mysql table. Below is what I have tried so far:
<strong>Authority Id: *</stong><select name="authid">
<?php
$authid = $row['AuthorityId'];
$selectedId = array(
5, 6, 7);
$selection = array(
5 => "Admin",
6 => "Employee",
7 => "Student" );
foreach($selection as $value){
$text = $value;
echo '<option value="'.$selectedId.'" selected="'.$authid.'">'.$text.'</option>';
}
?>
</select>
But it's not displaying the correct value. Can someone help me figure out what went wrong here? Thanks.