dpqvwgr74759 2018-12-06 04:53
浏览 31

插入多个相同的输入名称字段codeigniter

id    userid    fldWorkHistoryCompanyName    fldWorkHistoryJoiniedDate
1        1                 abc company                               2016.12.03
2        1                 def company                                2017.12.03
3        1                 ghi company                                2018.12.03
4        2                 ask company                                2014.12.03

<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 1" >

<input type="text" class="form-control"  name="fldWorkHistoryJoiniedDate[]" >

<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 2" >

<input type="text" class="form-control"  name="fldWorkHistoryJoiniedDate[]" >

<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 3" >

<input type="text" class="form-control"  name="fldWorkHistoryJoiniedDate[]" >

how to insert multiple name filed in codeigniter

</div>
  • 写回答

3条回答 默认 最新

  • dongnan1989 2018-12-06 05:32
    关注

    In order to insert multiple input text values in database using single name.

    You can make a form with method POST and put these fields into form and when you submit the button you can put the action into your controller.

    In the controller, you can do

    $history[] = $_Post['fldWorkHistoryCompanyName'];
    
    foreach ($history as $key => $value) {
      // make insert query and your value is in the $value variable.
    }
    

    OR

    If you have active records then you can to do this:

    $data = array(
       array(
          'userid' => '1' ,
          'fldWorkHistoryCompanyName' => 'Name' ,
          'fldWorkHistoryJoinedDate' => 'My date'
       ),
       array(
          'userid' => '2' ,
          'fldWorkHistoryCompanyName' => 'Another Name' ,
          'fldWorkHistoryJoinedDate' => 'Another date'
       )
    );
    
    $this->db->insert_batch('mytable', $data);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制