dongru2019 2018-05-25 06:18
浏览 49

如何使用for循环php从Add More动态追加多个选择框值来节省价值?

I am using append multi select box with some input text box also. i want save all data into table using for loop one by one. I m finished this but problem is i couldn't implode multi select box value inside of for loop. i want store each loop individual in table.It always save first record only in team(multiselectbox value) Please help me.

My View Screenenter image description here

My controller :

public function saveprogress()
{

    $project_id=$this->input->post('project_id');
    $prog_date=$this->input->post('date');
    $task=$this->input->post('task');
    $team = $this->input->post('team');
    $report=$this->input->post('report');

    $numFields = count($prog_date);
    $teamFields = count($team);

    for ($i = 0; $i < $numFields; $i++) {
        // Pack the field up in an array for ease-of-use.
        $field = array(
           'prog_date' => $prog_date[$i],
           'task' => $task[$i],
           'team' => $team[$i],
           'report' => $report[$i],
           'project_id' => $project_id
        );
     $result=$this->db->insert('progress', $field);
    }
    }

My table after save (i selected 2 employee but store one in team column) :

enter image description here

  • 写回答

1条回答 默认 最新

  • douke7431 2018-08-13 11:48
    关注

    In view add [ ] square brackets after input name hope useful..

     <input type="text" name="date[]">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。