I am new to codeigniter and trying to capture multiple values from a single form to update my database.
Here is the controller:
public function update_tb_table_test(){
$tb_items = $_POST;
}
And the view:
<thead>
<tr>
<th>Payment ID</th>
<th>Customer ID</th>
<th>Date</th>
</thead>
<tbody>
<tr>
<td><input type="text" name="update" id="comment_plog" /></td>
<td><input type="text" name="update2" id="ar_id" /></td>
<td><input type="text" name="update3" id="date" /></td>
</tr>
<tr>
<td><input type="text" name="update" id="comment_plog" /></td>
<td><input type="text" name="update2" id="ar_id" /></td>
<td><input type="text" name="update3" id="date" /></td>
</tr>
<tr>
<td><input type="text" name="update" id="comment_plog" /></td>
<td><input type="text" name="update2" id="ar_id" /></td>
<td><input type="text" name="update3" id="date" /></td>
</tr>
</tbody>
The result of print_r is
Array ( [update] => 3 [update2] => 4 [update3] => 5 )
which are the last three values in my input boxes only from the last row. I know I need to loop through each row but I am not sure how to set this up. I have also tried $tb_items = $this->input->post(NULL, TRUE); and it only returns 5, the very last value.
I haven’t included the model because I want to have the print_r returning the correct values before I move on to that. Thanks in advance for your help.
You should use
Notice
[]in the name. So you will get something likeand can loop through each field like
and
and so on.