title: How to insert values into database when input names are like- name="fieldname[]?
body: <p>I have the following form, I have to insert the form values into database. But I don't how to insert these values when the field names are like - name="fieldname[]". For better understanding please check the following. </p>
  
  <p>I am using Codeigniter. I have Views, controller and model, I have tried the usual way of inserting value but its not working. </p>
  
  <p>One of my friends suggested me to use something like- mysql_real_escape_string($value) but I don't know how to use it. Would you please kindly help me?   </p>
  
  <p>Thanks in Advance :)</p>
  
  <pre><code>   &lt;table&gt; 
       &lt;form &gt;
  
     &lt;tr&gt;
  
        &lt;td&gt; Student ID: &lt;input type="text" name="studentid[]" value="" /&gt; &lt;/td&gt;
        &lt;td&gt; Grade &lt;input type="text" name="grade[]" value="" /&gt;&lt;/td&gt;
        &lt;td&gt;Obtained Mark  &lt;input type="text" name="obtainedmark[]" value="" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
  
       &lt;td&gt; Student ID: &lt;input type="text" name="studentid[]" value="" /&gt; &lt;/td&gt;
       &lt;td&gt; Grade &lt;input type="text" name="grade[]" value="" /&gt;&lt;/td&gt;
       &lt;td&gt;Obtained Mark  &lt;input type="text" name="obtainedmark[]" value="" /&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
  
  
    &lt;tr&gt;
       &lt;td&gt; &lt;input type="submit" value="Submit" name="Submit" /&gt;&lt;/td&gt;
   &lt;/tr&gt;
  
   &lt;/form&gt;
   &lt;/table&gt;
  </code></pre>
  
  <h1>Edit </h1>
  
  <pre><code>    foreach($_POST['studentid'] as $studentid) {
        // do something
  
      $data = array(              
      'subjectname' =&gt;"",
      'subjectname' =&gt; $studentid             
  
      );                  
      $results=$this-&gt;db-&gt;insert('subject', $data);                      
  </code></pre>