azmicolejr

update ci

Oct 20th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. Controller:
  2. public function update($id)
  3. {
  4. $row = $this->Berita_model->get_by_id($id);
  5. if ($row)
  6. {
  7. $this->data['id'] = array(
  8. 'name' => 'id',
  9. 'id' => 'id',
  10. 'type'=> 'hidden'
  11. );
  12.  
  13. $this->data['judul'] = array(
  14. 'name' => 'judul',
  15. 'id' => 'judul',
  16. 'type' => 'text',
  17. 'class' => 'form-control',
  18. 'value' => $this->form_validation->set_value('title',$row->judul),
  19. );
  20.  
  21. $this->load->view('berita_update', $this->data);
  22. }
  23. else
  24. {
  25. $this->session->set_flashdata('message', 'Data tidak ditemukan');
  26. redirect(site_url('berita'));
  27. }
  28. }
  29.  
  30. Model:
  31. function get_by_id($id)
  32. {
  33. $this->db->where($this->id, $id);
  34. return $this->db->get($this->table)->row();
  35. }
  36.  
  37. View:
  38. <?php echo form_input($id);?>
  39. <div class="form-group"><label>Title</label>
  40. <?php echo form_input($title);?>
  41. </div>
  42. <div class="form-group"><label>Gambar Sebelumnya</label>
  43. <img src="assets/images/berita/<?php echo $userfile.'_thumb'.$userfile_type ?>" >
  44. </div>
Advertisement
Add Comment
Please, Sign In to add comment