简体   繁体   English

当我单击更新按钮时,它不会更改/更新(CodeIgniter,更新多行)

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

This is my controller: 这是我的控制器:

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))
}

When I click button Save , it won't change anything. 当我单击保存按钮时,它不会更改任何内容。 How can I fix this problem? 我该如何解决这个问题?

  <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> 

This is my model: 这是我的模型:

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

Here is my saveUpdate function 这是我的saveUpdate函数

i hope this helpyou 希望对您有帮助

view.php 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 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);
    }
}

model.php model.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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM