• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
INSERT DATA in few column

#1
[eluser]giriayoga[/eluser]
I want inserting data in few column on 1 tabel...how the code in model and controller??? thanks
Model
Code:
function register($data){
   $no_akta = $this->input->post('data[no_akta]');
   $tgl_akta = $this->input->post('data[tgl_akta]');
   $notaris_akta = $this->input->post('data[notaris_akta]');
   $data = array(
      array(
      'No_Akta_Pendirian_Prsh' => $no_akta ,
      'Tgl_Akta_Pendirian_Prsh' => $tgl_akta ,
      'Notaris_Pem_Akta' => $notaris_akta
      )
   );

   $this->db->insert_batch('rekanan',$data);
  }
Controller
Code:
function register(){
$form_data = $this->input->post('data');
  
        if(!empty($form_data)){
       $this->akta_pendirian_perusahaan_model->register($form_data);
redirect('rekanan/akta_pendirian_perusahaan/index');
}
  $this->load->view('rekanan/header');
         $this->load->view('rekanan/kiri');
  $this->load->view('rekanan/menu_data_administrasi');
    $this->load->view('rekanan/edit_akta_pendirian_perusahaan');
  $this->load->view('rekanan/footer');
    
  }
Views
Code:
<form id="form1" name="form1" method="post" action="">
  <table width="322" border="0">
    <tr>
      <td colspan="2">Edit Akta pendirian perusahaan</td>
    </tr>
    <tr>
      <td>No Akta</td>
      <td><label for="data[no_akta]"></label>
      &lt;input type="text" name="data[no_akta]" id="data[no_akta]" /&gt;&lt;/td>
    </tr>
    <tr>
      <td>Tanggal</td>
      <td><label for="data[tgl_akta]"></label>
      &lt;input type="text" name="data[tgl_akta]" id="tgl" /&gt;&lt;/td>
    </tr>
    <tr>
      <td>Notaris</td>
      <td><label for="data[notaris_akta]"></label>
      &lt;input type="text" name="data[notaris_akta]" id="data[notaris_akta]" /&gt;&lt;/td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&lt;input type="submit" name="button" id="button" value="Simpan" class="buttonedit" /&gt;&lt;/td>
    </tr>
  </table>
&lt;/form&gt;

#2
[eluser]LuckyFella73[/eluser]
Please post the code you have so far and describe where you got stuck.
Then we can help you to get your code to work.

Don't forget to read the User Guide:
http://ellislab.com/codeigniter/user-guide/toc.html

Especially the sections "controllers", "models" and "Database Class"

#3
[eluser]giriayoga[/eluser]
yeah...my thread was edited...how this solution...???

#4
[eluser]LuckyFella73[/eluser]
Thanks for posting the code now.

What happens when you submit the form? Can you describe
what doesn't work - do you get an error message?
And do you have a reason for using "insert_batch" to
insert your form data? Your name attributes look uncommon
too (at least I haven't seen it that way). If you need arrays
as input field names you usually do this:

Code:
&lt;input type="text" name="your_name[]" value="" /&gt;

Looking at the code you provided there is no need to use arrays
here. Correct me if I'm wrong.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.