EllisLab text mark
Advanced Search
     
INSERT DATA in few column
Posted: 04 October 2012 02:00 AM   [ Ignore ]
Joined: 2012-10-04
4 posts

I want inserting data in few column on 1 tabel…how the code in model and controller??? thanks
Model

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

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

<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>
      <
input type="text" name="data[no_akta]" id="data[no_akta]" /></td>
    </
tr>
    <
tr>
      <
td>Tanggal</td>
      <
td><label for="data[tgl_akta]"></label>
      <
input type="text" name="data[tgl_akta]" id="tgl" /></td>
    </
tr>
    <
tr>
      <
td>Notaris</td>
      <
td><label for="data[notaris_akta]"></label>
      <
input type="text" name="data[notaris_akta]" id="data[notaris_akta]" /></td>
    </
tr>
    <
tr>
      <
td>&nbsp;</td>
      <
td><input type="submit" name="button" id="button" value="Simpan" class="buttonedit" /></td>
    </
tr>
  </
table>
</
form
 
Posted: 04 October 2012 04:17 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-25
1009 posts

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”

 
Posted: 04 October 2012 08:36 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-10-04
4 posts

yeah…my thread was edited…how this solution…???

 
Posted: 04 October 2012 10:29 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-25
1009 posts

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:

<input type="text" name="your_name[]" value="" /> 

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