title: Codeigniter 3: Insert array form to database
body: <p>I'm new with Codeigniter and I'm having some trouble inserting arrays into my database. An error kept popping out that I can't insert array to my database.</p>
  
  <p><strong>Here's my HTML form:</strong></p>
  
  <pre><code>&lt;?= form_open('profile/profile_submit'); ?&gt;
  &lt;table class="table table-hover table-striped table-responsive"&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th id="headCheckHide"&gt;&lt;/th&gt;
          &lt;th&gt;&lt;center&gt;Name&lt;/center&gt;&lt;/th&gt;
          &lt;th&gt;&lt;center&gt;Date of Birth&lt;/center&gt;&lt;/th&gt;
          &lt;th&gt;&lt;center&gt;Occupation&lt;/center&gt;&lt;/th&gt;
          &lt;th&gt;&lt;center&gt;Educ. attainment&lt;/center&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody id="sibTable"&gt;
      &lt;tr class="product-item"&gt;
              &lt;td&gt;
                  &lt;input type="text" class="form-control form-input" name="siblingName[]"&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" class="form-control form-input" name="siblingBirthDate[]"&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" class="form-control form-input" name="siblingOccupation[]"&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;select class="form-control form-input" name="siblingEducAttainment[]" &gt;
                  &lt;option value="" selected&gt;-Please select-&lt;/option&gt;
                  &lt;option value="less than high school"&gt;less than high school&lt;/option&gt;
                  &lt;option value="Some college but no degree"&gt;Some college but no degree&lt;/option&gt;
                  &lt;option value="Associates Degree"&gt;Associates Degree&lt;/option&gt;
                  &lt;option value="Elementary Graduate"&gt;Elementary Graduate&lt;/option&gt;
                  &lt;option value="Secondary Graduate"&gt;Secondary Graduate&lt;/option&gt;
                  &lt;option value="College Graduate"&gt;College Graduate&lt;/option&gt;
                  &lt;option value="Master's Degree"&gt;Master's Degree&lt;/option&gt;
                  &lt;option value="Professional Degree"&gt;Professional Degree&lt;/option&gt;
                  &lt;option value="Doctorate Degree"&gt;Doctorate Degree&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/td&gt;   
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;?= form_submit('submit','Save', 'class="btn btn-outline-primary waves-effect"');?&gt;
  &lt;?php echo form_close();?&gt;
  </code></pre>
  
  <p><strong>My Controller for the form</strong></p>
  
  <pre><code> public function profile_submit(){
      $siblings=array(
  
          'name' =&gt; $this-&gt;input-&gt;post('siblingName'),
          'birthDate' =&gt; $this-&gt;input-&gt;post('siblingBirthDate'),
          'occupation' =&gt; $this-&gt;input-&gt;post('siblingOccupation'),
          'educAttainment' =&gt; $this-&gt;input-&gt;post('siblingEducAttainment')
      );
  
      $this-&gt;profile_model-&gt;submit_profile($siblings);
      redirect('profile','refresh'); //name of the html file
  }
  </code></pre>
  
  <p><strong>My model for (profile_model.php)</strong></p>
  
  <pre><code> function submit_profile($siblings){
          $this-&gt;db-&gt;insert('tbl_st_profile_sibling',$siblings);
  }
  </code></pre>
  
  <p>this is my model with the error: <strong>can't insert array into database.</strong>
  Can anyone please help? thank you.</p>