codeigniter从下拉列表中返回null


codeigniter return null from dropdown

我的视图中有下拉列表

<div class="col-md-4">
<select id="news_category" name="ed_news_category"  class="form-control">
  <?php
  foreach ($news_category_data as $ncat ) {?>
    <option
    <?php
    if($cat_for_news->nc_id == $ncat->nc_id) { echo "selected" ;}
     ?>
       value="<?php $ncat->nc_id ?>"><?php echo $ncat->nc_id ," - ", $ncat->news_category_name ?>
     </option>
  <?php } ?>
</select>

在我的控制器中得到一个下拉列表的值,它返回的为空

'news_category_id' => string '' (length=0)

我的控制器是:

$ed_ne_data = array(
    'titel' => $this->input->post('ed_news_title') ,
    'content' => $this->input->post('ed_news_content') ,
    'news_category_id' => $this->input->post('ed_news_category') ,
    'img_url' => $this->newsModel->getNewsToEdit($ed_ne_id)->img_url,
    'created_at' => date("Y-m-d")
);

我是怎么解决的
感谢

因为您忘记了在选项值中回显值

更改

 value="<?php $ncat->nc_id ?>"

 value="<?php echo $ncat->nc_id ?>"
              ^^^^^