当我点击更新按钮时,它赢得了';t更改/更新(CodeIgniter,更新多行)


When I click the update button, it won't change/update (CodeIgniter, Update Multiple Rows)

这是我的控制器:

function update_agenda() {
    $id = $this->input->post['did'];
    $this->load->model('agenda_model');
    $data = array(
                      'nama' => $this->input->post('did'),
                      'keterangan' => $this->input->post('dketer')
                  );
    ($this->agenda_model->update($id, $data))
}

当我点击按钮保存时,它不会改变任何内容。如何解决此问题?

        <td>
            <input type ="checkbox" id="haha" class=checkbox1 name="checklist" value=<?php echo $agenda->id; ?>> <?php echo $agenda->id; ?>
        </td>
        <td>
            <input type="text" id="hide" name="did" value="<?php echo $agenda->id; ?>">
        </td>
        <td>
            <input type="text" name="dnama" id="nama_" value="<?php echo $agenda->nama; ?>" disabled />
        </td>
        <td>
            <input type="text" name="dketer" id="ket_" value="<?php echo $agenda->keterangan; ?>" disabled>
        </td>
         <?php }?>
        </td>
    </tr>
</table>
 <button onclick="saveUpdate()"> Save </button>

这是我的型号:

function update ($id,$data){
    $this->db->where('id', $id);
    $this->db->update('agenda', $data);
}

这是我的saveUpdate函数

我希望这能帮助你

view.php

        <td>
            <input type ="checkbox" id="haha" class=checkbox1 name="checklist" value=<?php echo $agenda->id; ?>> <?php echo $agenda->id; ?>
        </td>
        <td>
            <input type="text" id="hide" name="did" value="<?php echo $agenda->id; ?>">
        </td>
        <td>
            <input type="text" name="dnama" id="nama_" value="<?php echo $agenda->nama; ?>" disabled />
        </td>
        <td>
            <input type="text" name="dketer" id="ket_" value="<?php echo $agenda->keterangan; ?>" disabled>
        </td>
         <?php }?>
        </td>
    </tr>
</table>
 <button onclick="saveUpdate()"> Save </button>

controller.php

function update_agenda() {
    $this->load->model('agenda_model');
    $this->form_validation->set_rules('did', 'Did', 'trim|required|xss_clean');
    $this->form_validation->set_rules('dketer', 'Dketer', 'trim|required|xss_clean');
     if ($this->form_validation->run() === FALSE){
        echo 'ERROR';
    }
    else{
        $id = $this->input->post['did'];
        $data = array(
                      'nama'       => $this->input->post('did'),
                      'keterangan' => $this->input->post('dketer')
                  );
        $this->agenda_model->update($id, $data);
        $data['agenda']   = $this->agenda_model->get_data($id);
        $this->load->view('formsuccess', $data);
    }
}

型号.php

function update($id, $data){
    $this->db->where('id', $id);
    $this->db->update('table', $data);
}
function get_data($id){
    $this->db->where('id', $id);
    return $this->db->get('table')->row();
}