I want to ask, how to post ID to database from URL, I can see this ID in the last url. my Url :
http://localhost/rekammedis/index.php/pasien/tambah_rm/3
I'm using uri to get $id_pasien value but when I post to database this value is null/empty not posted.
my model :
function tambahrm($id)
{
$this->load->helper('url');
$username = trim($this->session->userdata('id'));
$id_pasien = $this->uri->segment(3);
$data = array(
'tgl_berobat' => $this->input->post('tgl_berobat'),
'anamnesa' => $this->input->post('anamnesa'),
'diagnosa' => $this->input->post('diagnosa'),
'therapi' => $this->input->post('therapi'),
'keterangan' => $this->input->post('keterangan'),
'id_user' => $username,
'id_pasien' => $id_pasien,
);
if ($id == 0) {
return $this->db->insert('tbl_riwayat', $data);
} else {
$this->db->where('id', $id);
return $this->db->update('tbl_riwayat', $data);
}
}
here is result : Id_pasien remains unfilled.