Hallo! Selamat Datang di Marketplace produk digital, Freelancer terbaik di indonesia (67523 Members, 783 Products, 5293 Topic, 12956 Comments)

CODEIGNITER-bagaimana supaya ID langsung ke save

Dibuat
Login Terakhir 8 Bulan lalu,
Telah Dilihat 1285 Kali
indrianto adi Mengatakan : Sultan Account
  1. Assallmualaikm mas robby
  2. saya punya kasus seperti ini
  3. di view tampilannya ,, menggunakan select dan form input biasa
  4. nahh bagaimana supaya ID yang di select(untuk menampilkan datanya terlebih dahulu sesuai id) bisa ikut ke save pada saat klik tombol save, berikut gambarnya dan scriptnya
  5.  
  6. script controllers
  7.  
  8. function tampil_save(){
  9. cek_session_admin();
  10. $id = $this->uri->segment(3);
  11. if (isset($_POST['submit'])){
  12.  
  13. $this->model_main->updatedata();
  14. $this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-success\" id=\"alert\">Data berhasil diupdate!! </div></div>");
  15.  
  16. redirect('Keuangan/tampil_save');
  17. }else{
  18. $data['rows'] = $this->model_main->tampil_save($id)->row_array();
  19.  
  20. $data['agentcabang'] = $this->model_main->joincabang();
  21. $this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Gagal!!</div></div>");
  22.  
  23. $this->template->load('Cpanelweb/template','Cpanelweb/mod_cabang/view_tampil_save',$data);
  24. }
  25. }
  26.  
  27.  
  28. view view_tampil_save.php
  29. <?php
  30. echo "<div class='col-md-12'>
  31. <div class='box box-info'>
  32. <div class='box-header with-border'>
  33. <h3 class='box-title'>Data pesanan</h3>
  34. </div>
  35. <div class='box-body'>";
  36. $attributes = array('class'=>'form-horizontal','role'=>'form');
  37. echo form_open_multipart('Keuangan/tampil_save',$attributes);
  38. echo "<div class='col-md-12'>
  39. <table class='table table-condensed table-bordered'>
  40. <tbody>
  41. <input type='hidden' name='id' value='$rows[id_]'>
  42. <tr>
  43. <th width='120px' scope='row'>Nama Paket </th> <th>:</th> <th>$rows[nama_paket]</th>
  44. </tr>
  45. <tr>
  46. <th width='120px' scope='row'>Program hari </th> <th>:</th> <th>$rows[program_hari]</th>
  47. </tr>
  48. <tr>
  49. <th width='250px' scope='row'>Keberangkatan tanggal </th> <th>:</th> <th>$rows[keberangkatan_tanggal]</th>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. <div class='col-md-12'>
  56. <table class='table table-condensed table-bordered'>
  57. <tbody>
  58. <input type='hidden' name='id' value='$rows[id_]'>
  59. <tr>
  60. <th width='120px' scope='row'>Nama Depan</th>
  61. <td><input type='text' name='nama_depan' class='form-control'></td>
  62. <th width='120px' scope='row'>Nama Tengah</th>
  63. <td><input type='text' name='nama_tengah' class='form-control'></td>
  64. </tr>
  65. <tr>
  66.  
  67. <th width='120px' scope='row'>Nama Belakang</th>
  68. <td><input type='text' name='nama_belakang' class='form-control'></td>
  69. <th width='120px' scope='row'>Alamat</th>
  70. <td><textarea type='text' name='alamat' class='form-control'></textarea></td>
  71. </tr>
  72. <tr>
  73.  
  74. <th width='120px' scope='row'>Tanggal lahir</th>
  75. <td><input type='text' name='tgl_lahir' id='tgl_lahir' class='form-control'></td>
  76. <th width='120px' scope='row'>Tempat lahir lahir</th>
  77. <td><input type='text' name='tempat_lahir' class='form-control'></td>
  78. </tr>
  79. <tr>
  80.  
  81. <th width='120px' scope='row'>No HP</th>
  82. <td><input type='text' name='no_hp' class='form-control'></td>
  83. <th width='120px' scope='row'>No tlp</th>
  84. <td><input type='text' name='no_tlp' class='form-control'></td>
  85. </tr>
  86. <tr>
  87.  
  88. <th width='120px' scope='row'>Email</th>
  89. <td><input type='email' name='email' class='form-control'></td>
  90. <th width='120px' scope='row'>Virtual account</th>
  91. <td><input type='text' name='no_virtual_account' class='form-control'></td>
  92. </tr>
  93. <tr>
  94.  
  95. <th width='120px' scope='row'>Tgl issued</th>
  96. <td><input type='email' name='tgl_issued' id='tgl_issued' class='form-control'></td>
  97. <th width='120px' scope='row'>Tgl expired</th>
  98. <td><input type='text' name='tgl_expired' id='tgl_expired' class='form-control'></td>
  99. </tr>
  100. <tr>
  101.  
  102. <th width='120px' scope='row'>Tempat imigrasi</th>
  103. <td><input type='text' name='tempat_imigrasi' id='tgl_issued' class='form-control'></td>
  104. <th width='120px' scope='row'>Marketing agent</th>
  105. <td>
  106.  
  107. <select name='marketing_agent' class='form-control'>
  108. <option value='0'>--pilih refrensi marketing --</option>";
  109. foreach ($agentcabang->result_array() as $row){
  110. if ($rows['id_agent'] == $row['id_agent']){
  111. echo "<option value='$row[id_agent]' selected>$row[nama_agent_cabang]</option>";
  112. }else{
  113. echo "<option value='$row[id_agent]'>$row[nama_agent_cabang]</option>";
  114. }
  115. }
  116. echo "</td></tr>
  117. </tbody>
  118. </table>
  119. </div>
  120. <div class='box-footer'>
  121. <button type='submit' name='submit' class='btn btn-primary'>Save</button>
  122. <a href='../listbranch'><button type='button' class='btn btn-default pull-right'>Cancel</button></a>
  123.  
  124. </div>
  125. </div>";
  126.  
  127. //mODEL
  128. function updatedata(){
  129.  
  130. $datadb = array('id_'=>$this->db->escape(trim($this->input->post('id'))),
  131. 'nama_depan'=>$this->db->escape_str(trim($this->input->post('nama_depan'))),
  132. 'nama_tengah'=>$this->db->escape_str(trim($this->input->post('nama_tengah'))),
  133. 'nama_belakang'=>$this->db->escape_str(trim($this->input->post('nama_belakang'))),
  134. 'alamat'=>$this->db->escape_str(trim($this->input->post('alamat'))),
  135. 'tgl_lahir'=>$this->db->escape_str(trim($this->input->post('tgl_lahir'))),
  136. 'tempat_lahir'=>$this->db->escape_str(trim($this->input->post('tempat_lahir'))),
  137. 'email'=>$this->db->escape_str(trim($this->input->post('email'))),
  138. 'no_hp'=>$this->db->escape_str(trim($this->input->post('no_hp'))),
  139. 'no_telp'=>$this->db->escape_str(trim($this->input->post('no_telp'))),
  140. 'no_virtual_account'=>$this->db->escape_str(trim($this->input->post('no_virtual_account')))
  141. //'id'=>$this->db->escape_str($this->input->post('nama_bank'))
  142. );
  143. $this->db->where('id_cus',$this->input->post('id'));
  144. $this->db->update('tbl_customer',$datadb);
  145. }
Ada 1 File Kiriman :
1. ade344.png (87 KB)
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!