title: Insert value to database in CodeIgniter; I have array <input> tag
body: <p>How can I insert a value to database having an array values in my <code>&lt;input&gt;</code> tag. I'm making online library system; this part is I'm adding a book to database sometimes a book have more than 1 author.</p>
  <p>Now I use implode to insert but the 2 authors are sharing in 1 one column. What I want they have to be in different column when inserting to tbl_authors. I insert book details to tbl_books and for authors in tbl_authors. I've tried for each but I can only do it when displaying data when insert I have no idea</p>
  <pre><code>   foreach($test as value)
     {
     'author_name' =&gt; $value[' no idea what i need to put here']
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/FlBe5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FlBe5.png" alt="Html Code" /></a></p>
  <p><a href="https://i.stack.imgur.com/LcYFC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LcYFC.png" alt="Add Book Page" /></a></p>
  <p><a href="https://i.stack.imgur.com/uBA5o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uBA5o.png" alt="Problem, 2 authors sharing on 1 column. I need To separate them" /></a></p>
  <pre><code>  public function insertbooks()
              {
                $data=array(
              'book_id'         =&gt;        $this-&gt;db-&gt;insert_id(),
              'book_title'    =&gt;      $this-&gt;input-&gt;post('booktitle',true),
              'section_id'      =&gt;        $this-&gt;input-&gt;post('section',true),
              /*'book_author'   =&gt;        $this-&gt;input-&gt;post('bookauthor',true),*/
              'book_serial'   =&gt;    $this-&gt;input-&gt;post('serial',true),
              'book_qty'      =&gt;      $this-&gt;input-&gt;post('bookqty',true),
              );
              $sql1  = $this-&gt;db-&gt;insert('tbl_books',$data);
              $author_name=implode(',', $this-&gt;input-&gt;post('bookauthor',true));
              $data2=array(
              'book_id'       =&gt;    $this-&gt;db-&gt;insert_id(),
              'author_name'   =&gt;    $author_name
              );
              $sql2  = $this-&gt;db-&gt;insert('tbl_authors',$data2);
              }
  </code></pre>