Welcome Guest, Not a member yet? Register   Sign In
Inserting For each?
#11

[eluser]Dizza[/eluser]
[quote author="Glazz" date="1339442077"]After you submit your form, try using this code to see what you are exactly getting from the form:
Code:
var_dump( $this->input->post() );
or
Code:
var_dump( $this->input->post('aanwezigheid') );

Inside the foreach, you place your mysql query, but you need change the values of course, so it will be automatically.[/quote]

Haha thanks! Im almost there now Tongue

My model looks like this now
Code:
function updateAanwezigheid($data)
{
  foreach ( $this->input->post('aanwezigheid') as $ID => $aanwezigheid )
  {
   $this->db->insert('aanwezigheid', $data);
  }
   echo "Added";
  return;  
}

And my controller
Code:
function insert(){
$this->is_logged_in();

if($this->input->post('submit')){
    $this->load->model('aanwezigheid_model');
    
     $ID = $this->input->post('ID');
   $lesuur   = $this->input->post('lesuur');
   $aanwezigheid   = $this->input->post('aanwezigheid');
    
     $this->aanwezigheid_model->updateAanwezigheid($data);
  }
  
  $this->load->view('aanwezigheidklas_view' );    
}

When i used the var_dump all data was there but now i get this error, that while im not even updating Tongue
Code:
You must use the "set" method to update an entry.

Filename: /Users/jimmytenbrink/Sites/afstuderen/models/aanwezigheid_model.php

Line Number: 9


Messages In This Thread
Inserting For each? - by El Forum - 06-11-2012, 07:15 AM
Inserting For each? - by El Forum - 06-11-2012, 10:18 AM
Inserting For each? - by El Forum - 06-11-2012, 10:35 AM
Inserting For each? - by El Forum - 06-11-2012, 10:40 AM
Inserting For each? - by El Forum - 06-11-2012, 10:49 AM
Inserting For each? - by El Forum - 06-11-2012, 10:58 AM
Inserting For each? - by El Forum - 06-11-2012, 11:03 AM
Inserting For each? - by El Forum - 06-11-2012, 11:07 AM
Inserting For each? - by El Forum - 06-11-2012, 12:08 PM
Inserting For each? - by El Forum - 06-11-2012, 12:14 PM
Inserting For each? - by El Forum - 06-11-2012, 12:42 PM
Inserting For each? - by El Forum - 06-11-2012, 01:03 PM
Inserting For each? - by El Forum - 06-11-2012, 01:24 PM
Inserting For each? - by El Forum - 06-11-2012, 01:31 PM
Inserting For each? - by El Forum - 06-11-2012, 02:06 PM
Inserting For each? - by El Forum - 06-11-2012, 02:45 PM
Inserting For each? - by El Forum - 06-11-2012, 03:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB