Inserting number of rows and input post usage
<p>I am trying to insert data into a table in a <code>for</code> loop:</p>

<pre><code>public function insertprolist()
{     
    for ($i = 1; $i &lt; $this-&gt;input-&gt;post('numrows'); $i = $i + 1)
    {
        $data = array(
            'productname' =&gt; $this-&gt;input-&gt;post('proname'+$i),
            'quantity' =&gt; $this-&gt;input-&gt;post('quantity'+$i),
            'price' =&gt; $this-&gt;input-&gt;post('price'+$i),
            'amount' =&gt; $this-&gt;input-&gt;post('amount'+$i)
        );
        return $this-&gt;db-&gt;insert('purchaseprolist', $data);   
    }
}
</code></pre>

<p>I am getting an error.</p>

<p>It is not getting inserted into the database table.</p>

<p>I have appended new rows with input fields with names such as <code>proname1</code>, <code>quantity1</code> and for the second row the input name attribute will be generated as <code>proname2</code>, <code>quantity2</code> and it goes on.</p>

<p>I am retrieving the number of rows in another input with name <code>numrows</code>.</p>

<p>Now I want to access these inputs in modal file.</p>