如何在引导选择器中将多重选择插入MySQL Codeigntor

时间:2019-04-16 13:42:08

标签: codeigniter

我认为

   <div class="col-md-6 col-sm-6 col-xs-12">
        <select  class="selectpicker form-control col-md-7 col-xs-12 select2"  name="teacher_id[]"  id="add_teacher_id"  required="required" multiple data-selected-text-format="count > 3" data-live-search="true" dir="rtl" data="pull-right" data-style="text-right" >
                <option value="">--<?php echo $this->lang->line('select'); ?>--</option> 
                <?php foreach($teachers as $obj ){ ?>
                      <option value="<?php echo $obj->id; ?>" <?php echo isset($post['teacher_id']) && $post['teacher_id'] == $obj->id ?  'selected="selected"' : ''; ?>><?php echo $obj->name; ?></option>
                <?php } ?>                                            
        </select>

处于控制状态

private function _get_posted_section_data() {

        $items = array();

        foreach($this->input->post('teacher_id') as $key=>$value){
            $items[] = 'school_id';
            $items[] = 'class_id';
           //$items['teacher_id'] = $value;
            $items[] = 'name';
            $items[]  = @$_POST['teacher_id'][$key];
            $data = elements($items, $_POST);        
            $data['note'] = $this->input->post('note');
           //$data['teacher_id']  = @$_POST['teacher_id'][$key];           
         }
        if ($this->input->post('id')) {
            $data['modified_at'] = date('Y-m-d H:i:s');
            $data['modified_by'] = logged_in_user_id();
        } else {
            $data['status'] = 1;
            $data['created_at'] = date('Y-m-d H:i:s');
            $data['created_by'] = logged_in_user_id();                       
        }

        return $data;
    }

0 个答案:

没有答案