How to use dropbox |
iam newbe....please help.
I still confuse to use dropbox on my aplication. I want to change text field with drop box but never success. dropbox content fill from table (database). this my code : Model : <?php class M_crud extends CI_Controller{ function __construct(){ parent::__construct(); $this->load->database(); } function m_lihat(){ $lihat = $this->db->get('kategori'); return $lihat->result(); function m_tambah_act($data) { $this->db->insert('kategori',$data); } function m_hapus($data) { $this->db->delete('kategori',$data); } function m_edit($data){ $this->db->where($data); $edit = $this->db->get('kategori'); return $edit->result(); } function m_update($data,$kode_kategori){ $this->db->where('kode_kategori', $kode_kategori); $this->db->update('kategori',$data); } } ?> =================================================== Controller <?php class Crud extends CI_Controller{ function __construct(){ parent::__construct(); $this->load->helper(array('url','form')); $this->load->model('m_crud'); function tbljenis() { $this->load->view('v_jenis_risiko'); } function lihat() { $data['data_kategori']=$this->m_crud->m_lihat(); $this->load->view('v_lihat',$data); } function tambah() { $this->load->view('v_tambah'); $data['data_kategori']=$this->m_crud->m_lihat(); $this->load->view('v_lihat',$data); } function tambah_act(){ $data=array( 'kode_kategori' => $this->input->post('kode_kategori'), 'nama_kategori' => $this->input->post('nama_kategori') ); $this->m_crud->m_tambah_act($data); redirect(base_url().'index.php/crud/tambah'); } function hapus($kode_kategori){ $data=array( 'kode_kategori' => $kode_kategori ); $this->m_crud->m_hapus($data); redirect(base_url().'index.php/crud/tambah'); } function edit($kode_kategori){ $data=array( 'kode_kategori'=>$kode_kategori ); $data['data_edit']=$this->m_crud->m_edit($data); $this->load->view('v_edit',$data); } function update() { $kode_kategori = $this->input->post('kode_kategori'); $data=array( 'kode_kategori' => $this->input->post('kode_kategori'), 'nama_kategori' => $this->input->post('nama_kategori') ); $this->m_crud->m_update($data,$kode_kategori); redirect(base_url().'index.php/crud/tambah'); } } ?> =============================================== View <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="<?php echo base_url().'css/style.css' ?>" /></head> <body> <table border="1"> <tr> <th>KODE</th> <th width="400">KATEGORI RISIKO</th> <th>OPSI</th> </tr> <?php foreach($data_kategori as $lihat){ ?> <tr> <td align="center"><?php echo $lihat->kode_kategori; ?></td> <td><?php echo $lihat->nama_kategori; ?></td> <td><?php echo anchor(base_url().'index.php/crud/hapus/'.$lihat->kode_kategori,'Hapus') ?> || <?php echo anchor(base_url().'index.php/crud/edit/'.$lihat->kode_kategori,'Edit') ?></td> </tr> <?php } ?> </table> <div align="center"><a href="http://localhost/belajar/index.php/crud/depan"><img src="<?php echo base_url(); ?>images/home.png" width="35" height="34"></a></div> </body> </html> Please help me..how to change coding above, i want to use dropbox in category select not text field. thanks.
To use a 'dropbox', you would need to have a form on the page and something like this as your form field:
Code: <select name="" id=""> Or you can use the form helper form_dropdown which might be easier which you can read about here: http://www.codeigniter.com/user_guide/he...m_dropdown
you have an error in your model class deffenition. Model Classes should extend CI_Model or MY_Model if you use one of them. Not CI_Controller.
"I reject your reality and substitute my own" - Adam Savage, M5 Inc.
|
Welcome Guest, Not a member yet? Register Sign In |