[英]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);
}
希望對您有幫助
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);
}
}
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.