Qotada Qotada - 7 months ago 57
PHP Question

Codeigniter missing argument

Help guys.
This my error problem error

I Think i follow right tutorial, but i dont know what the wrong from my code

there is my controlers

public function edit($id){
$where = array('id' => $id);
$data['barang'] = $this->model_barang->edit($where,'barang')->results();
$this->load->view('edit',$data);
}
public function update(){
$id = $this->input->post('id');
$jenis = $this->input->post('jenis');
$nama = $this->input->post('nama');
$harga = $this->input->post('harga');
$pemasok = $this->input->post('pemasok');

$data = array (
'jenis' => $jenis,
'nama'=> $nama,
'harga' => $harga,
'pemasok' => $pemasok
);

$where = array(
'id' => $id
);

$this->model_barang->update($where,$data,'barang');
redirect('barang/tampil');
}


and there is my model, i think my model is not showing any error

public function edit($where,$table) {
return $this->db->get($table,$where);
}
public function update($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}

Answer

You need to pass the $id to the controller. It should be something like this http://domain.com/barang/edit/1

Comments