update nilai isi dropdown menggunkan CI

mohon bantuannya gan, saya gk bisa update isi dropdown yg nilainya saya ambil dari database,bagaimana cara mengambil nilainya yah?? untuk script update di modelnya saya pake seperti query sql.

UPDATE VIEW


 <div class="form-group">
 <label class="control-label col-md-3 col-sm-3 col-xs-12">Kode Range</label>
    <div class="col-md-2 col-sm-2 col-xs-12" type="number">
        <select class="select2_single form-control" name="$kdrange">
             <option></option>
             <option value="one">1</option>
             <option value="two">2</option>
             <option value="for">4</option>
             <option value="six">6</option>
             <option value="ninetynine">99</option>
        </select>
    </div>
 </div>

MODEL


 function update_data()
    {
        $kdkntr = $this->input->post('kdkntr');
        $kdrange = $this->input->post('kdrange');
        $range_plf1 = $this->input->post('range_plf1');
        $range_plf2 = $this->input->post('range_plf2');
        $tkk1 = $this->input->post('tkk1');
        $tkk5 = $this->input->post('tkk5');
        $tkk2 = $this->input->post('tkk2');
        $tkk6 = $this->input->post('tkk6');

        $this->db->trans_begin();

$sql = "UPDATE PJ_KLP_TT SET KD_KNTR='$kdkntr',KD_RANGE='$kdrange',                                RANGE_PLF1='$range_plf1',RANGE_PLF2='$range_plf2',TKK1='$tkk1', TKK5='$tkk5',TKK2='$tkk2',TKK6='$tkk6' WHERE KD_RANGE = '$kdrange'";

            $update=$this->db->query($sql);

        if ($this->db->trans_status() == FALSE)
            {
                $this->db->trans_rollback();
                return FALSE;
            }
        else
            {
                $this->db->trans_commit();
                return $update;
            }
    }

CONTROLLER

 function update(){
            $kdkntr= $this->session->userdata('SESS_KD_KNTR');
            $user= $this->session->userdata('SESS_FIRST_NAME');

            $this->load->model('pemkepkredit_model');
            $datamenu['judul']='Pemeliharaan Keputusan Kredit';
            $datamenu['menu'] = $this->pemkepkredit_model->display_menu($user);
            $datamenu['data'] = $this->pemkepkredit_model->tampil_semua_data($kdrange);
            /*$datamenu['edit'] = $this->paranotaris_model->update_data();*/
            $this->load->view('pemkepkredit_data_view',$datamenu);
        }
function update_data(){
            $this->load->model('pemkepkredit_model');
            $this->pemkepkredit_model->update_data();
            $this->index();
        }
    }

avatar Faufauzi
@Faufauzi

15 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

2 Jawaban:

Coba ubah bagian ini:


<select class="select2_single form-control" name="$kdrange">

menjadi ini:


<select class="select2_single form-control" name="kdrange">

avatar keccikun
@keccikun

368 Kontribusi 197 Poin

Dipost 6 tahun yang lalu

tetep gk bisa gan, knapa yah.? padahal itu selain yg dropdown berhasil ngambil nilai, kok yg dropdown gk bisa.

avatar Faufauzi
@Faufauzi

15 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban