title: PHP codeigniter
body: <p>I'm using Codeigniter. My form has multiple rows with same fields name in each row. Could you please help me how can I save it in the database by looping. I'm getting an error</p>
  <blockquote>
  <p>Error Number: 1048 Column 'sn_unit' cannot be null</p>
  </blockquote>
  <p>Please see the below code. Thank you in advance for your help.</p>
  <p>This is the view</p>
  <pre><code>&lt;?php 
  for ($i = 1; $i &lt;= $number_to_check; $i++) {
  ?&gt;
  &lt;hr&gt;
  &lt;div class=&quot;row&quot;&gt;
     &lt;div class=&quot;col-xl-4&quot;&gt;
         &lt;div class=&quot;mb-3&quot;&gt;
            &lt;label class=&quot;form-label&quot;&gt;&lt;strong&gt;&lt;?php echo $i;?&gt;&lt;/strong&gt;&lt;/label&gt;
            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;sn_unit[]&quot; placeholder=&quot;Unit Serial Number&quot; required&gt;
         &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php 
  }
  ?&gt;
  </code></pre>
  <p>And this the controller</p>
  <pre><code>for ($i = 1; $i &lt;= count($this-&gt;input-&gt;post('sn_unit')); $i++) {
  
     $sn_unit = $this-&gt;input-&gt;post('sn_unit[$i]');
                
     $chk = $this-&gt;auth-&gt;saveItemReport();
  }
  
  </code></pre>