adeeva

mvc

May 11th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. //controler
  2. function tes(){
  3. $post = $this->input->post();
  4. $check = $post['id'];
  5. $q['data'] = $this->get_db->get_edit($post)->result();
  6. $q['data_count'] = $this->get_db->get_edit($post)->num_rows();
  7. $this->load->view('form', $q);
  8.  
  9. }
  10.  
  11. //-------------------------------
  12.  
  13.  
  14. //model
  15. function get_edit($post)
  16. {
  17. $this->db->select("id, nama, umur, kelas");
  18. $this->db->from("murid");
  19. $this->db->where_in('id', $post['id']);
  20. $this->db->order_by('id', 'DESC');
  21. $q = $this->db->get();
  22.  
  23. return $q;
  24. }
  25. //-------------------------------------------------
  26.  
  27.  
  28. //view
  29.  
  30. <div class="container">
  31. <div class="row">
  32.  
  33. <h1>Multi CRUD</h1>
  34. <?=form_open("multi_crud/sunting_proses");?>
  35. <fieldset>
  36. <legend><b>Sunting data</b></legend>
  37. <table cellpadding="5" cellspacing="5">
  38. <?php
  39. foreach ($data as $key => $v)
  40. {
  41. echo "
  42. <tr>
  43. <td><input type='text' name='id[]' value='{$v->id}'></td>
  44. <td><input type='text' name='nama[]' placeholder='nama' value='{$v->nama}'></td>
  45. <td><input type='number' name='umur[]' placeholder='umur' value='{$v->umur}' style='width:60px;'></td>
  46. <td><input type='number' name='kelas[]' placeholder='kelas' value='{$v->kelas}' style='width:60px;'></td>
  47. </tr>
  48. ";
  49. }
  50. ?>
  51. </table>
  52. <br>
  53. <br>
  54. <input class="btn btn-info" type="submit" name="sunting" value="Simpan perubahan">
  55. <input class="btn btn-default" type="reset" value="Reset">
  56. </fieldset>
  57. <?=form_close();?>
  58. </div>
  59. </div>
Advertisement
Add Comment
Please, Sign In to add comment