2017-03-13 07:17
浏览 50

在codeigniter中使用select multiple的内容填充PHP数组

In my view I have a form select multiple box where I add items using a select dropdown and a button like this.

This is how the code of the select multiple box looks after adding 3 items to it.

<label for="nombresFamilia" class="col-md-4 control-label"></label>
<div class="col-md-6">
   <select multiple id="nombresFamilia" name="nombresFamilia[]" class="form-control">
       <option value="CABLES">CABLES</option>
       <option value="PCR">PCR</option>
       <option value="POSTES">POSTES</option>

After submitting the form information, I want to save the items inside the select multiple into an array. This is the code I have in my controller.

function add()


        $params_familia = $this->input->post('nombresFamilia[]');  

However, when I try to var_dump the array

    echo "<pre>";
    echo "</pre>";

I get the message: "Undefined variable: params_familia".

What am I doing wrong?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题