[add_library form ]
<select name="employee_id" class="form-control">
<option value="">Select Employee.....</option
<?php
if (!empty($employee_info) && is_array($employee_info)){
foreach ($employee_info as $emp_info) {
// blow option of compare db id and select option value ?>
<option <?php echo ($emp_info->employee_id==$library_info->employee_id ) ? 'selected' : ''; ?>
value="<?php echo $emp_info->employee_id; ?>">
<?php echo $emp_info->first_name . ' ' . $emp_info->last_name ?>
</option>
<?php
}
}
?>
</select>
here is screen shot of front end. Am new in developing. thanks for help in advance . this is the pic of front end
I'm not entirely sure how you have this set up, because I wouldn't do it this way. But try this:
<select name="employee_id" class="form_control">
<option value="">Select Employee...</option>
<?php
if (!empty($employee_info)) { // Left out the is_array. You can check one or the other. empty only checks arrays. Can include it to be thorough
foreach ($employee_info AS $ei) {
echo '<option value="' . $ei->employee_id . '"';
echo ($ei->employee_id == $library_info->employee_id) ? ' SELECTED ' : '' . '>';
echo $ei->first_name . ' ' . $ei->last_name;
echo '</option>'.PHP_EOL;
}
}
?>
</select>
It may take a little tweaking.