Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Controller:
- public function update($id)
- {
- $row = $this->Berita_model->get_by_id($id);
- if ($row)
- {
- $this->data['id'] = array(
- 'name' => 'id',
- 'id' => 'id',
- 'type'=> 'hidden'
- );
- $this->data['judul'] = array(
- 'name' => 'judul',
- 'id' => 'judul',
- 'type' => 'text',
- 'class' => 'form-control',
- 'value' => $this->form_validation->set_value('title',$row->judul),
- );
- $this->load->view('berita_update', $this->data);
- }
- else
- {
- $this->session->set_flashdata('message', 'Data tidak ditemukan');
- redirect(site_url('berita'));
- }
- }
- Model:
- function get_by_id($id)
- {
- $this->db->where($this->id, $id);
- return $this->db->get($this->table)->row();
- }
- View:
- <?php echo form_input($id);?>
- <div class="form-group"><label>Title</label>
- <?php echo form_input($title);?>
- </div>
- <div class="form-group"><label>Gambar Sebelumnya</label>
- <img src="assets/images/berita/<?php echo $userfile.'_thumb'.$userfile_type ?>" >
- </div>
Advertisement
Add Comment
Please, Sign In to add comment