title: How to post multiple inputs in database
body: <p>I'm working with Codeigniter, on a sales targets' form for salesmen.
  They have to input values for each product, locality, year, etc.
  Product and locality are already get with existing database: no need to set rules (see controller).</p>
  <p>When I checked the post (with enable_profiler of Codeigniter), I get this:
  <a href="https://i.stack.imgur.com/giH8v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/giH8v.png" alt="enable_profiler result" /></a></p>
  <p>The problem is these datas don't insert into the database table.
  I read and tested a lot, but always blocked.</p>
  <p>Here is my model:</p>
  <pre><code>    public function add($params)
          {
              $this-&gt;db-&gt;insert($this-&gt;table, $params);
              return $this-&gt;db-&gt;insert_id();
          }
  
  </code></pre>
  <p>My controller:</p>
  <pre><code>    $this-&gt;load-&gt;library('form_validation');
      
              $this-&gt;form_validation-&gt;set_rules('year', 'Year', 'required|integer');
              $this-&gt;form_validation-&gt;set_rules('prevision', 'Prevision', 'required');
              $this-&gt;form_validation-&gt;set_rules('value', 'Value', 'required|integer');
              
              if ($this-&gt;form_validation-&gt;run()) {
                  $params = array(
                      'year' =&gt; $this-&gt;input-&gt;post('year'),
                      'prevision' =&gt; $this-&gt;input-&gt;post('prevision'),
                      'locality_id' =&gt; $this-&gt;input-&gt;post('locality'),
                      'product' =&gt; $this-&gt;input-&gt;post('product'),
                      'value' =&gt; $this-&gt;input-&gt;post('value'),
                  );
      
                  $this-&gt;Objectif_model-&gt;add($params);
                  redirect('admin/objectif');
              } else {
                  $this-&gt;layout('admin/objectif/add');
              }
  
  </code></pre>
  <p>And my view with inputs:</p>
  <pre><code>&lt;?php foreach ($products as $product) : ?&gt;
  &lt;tr class=&quot;form-group&quot;&gt;
      &lt;td class=&quot;bg-warning&quot;&gt;
      &lt;?= $product-&gt;grp_product; ?&gt;
      &lt;/td&gt;
      &lt;td class=&quot;bg-warning product&quot;&gt;
      &lt;?= $product-&gt;code; ?&gt;
      &lt;/td&gt;
          &lt;?php foreach ($localities as $locality ) : ?&gt;
          &lt;td&gt;
              &lt;input type=&quot;text&quot; class=&quot;form-control valeur&quot; placeholder=&quot;Value k€&quot; name=&quot;value[]&quot; data-validation=&quot;number&quot; data-validation-ignore=&quot;./&quot; data-validation-optional=&quot;true&quot; /&gt;
              &lt;input type=&quot;text&quot; name=&quot;year[]&quot; /&gt;
              &lt;input type=&quot;text&quot; name=&quot;prevision[]&quot; /&gt;
              &lt;input type=&quot;text&quot; name=&quot;product[]&quot; value=&quot;&lt;?= $product-&gt;code ?&gt;&quot; /&gt;
              &lt;input type=&quot;text&quot; name=&quot;localite_id[]&quot; value=&quot;&lt;?= $locality-&gt;id ?&gt;&quot; /&gt;
          &lt;/td&gt;
          &lt;?php endforeach; ?&gt;
  &lt;/tr&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  <p>Hope you will help me.</p>