已选择HTML ="已选择"最初没有工作

时间:2016-04-26 01:51:39

标签: php html laravel-4

所以我有这个选择框,其中包含一个人的个人资料中的位置列表。打开页面时,它应显示该特定人员的选定位置。但是,它第一次不起作用,但是当我改变位置并保存它时,它现在将显示所选位置。我不需要那样就可以工作。

这是我的代码:

   <select name="position" id="position" class="form-control">
       <option></option>
       <?php
       $post = DB::table('ccl_position')->orderBy('position_name', 'asc')->get();
       foreach ($post as $pos)
       {
       ?>
       <option<?=($pos->ccl_position_id==$crew->position ? ' selected="selected"' : '')?> value="<?=$pos->ccl_position_id?>"><?=$pos->position_name?></option>
       <?php } ?>
   </select>

&#34; $ crew-&gt;位置&#34;是所述人的选定职位。

here is what it looks like when opening the profile for the first time

after I changed the position and update it. it will now display the selected position

0 个答案:

没有答案
相关问题