i have form in which five fields are displaying in one row.. two of them are select boxes and the remaining are simple input boxes .. i put this row in a for loop which is less then five so now my form has five rows each contain two dropdown and three textboxes .. i want to take their values into the controller.. how am i gonna do that ..? as i am new in code igniter so dont know how to i take their parameters in an controller as an array ... here is my code ..the code is not working..it is storing 0 for price and quantity and in a database
<?php for ($i = 0; $i < 5; $i++) {
?>
<tr>
<td><?php echo form_dropdown('cat_id[]', $records2,
'#', "id='category_".$i."' onchange='getItems(this.value,".$i.")' ");?>
</td>
<!-- Items -->
<td> <?php echo form_dropdown('item_id[]',
$records3, '#', "id='items_".$i."'"); ?></td>
<!-- end of Items -->
<td><input type="text" name = "price_<?php echo $i ?>"
id = "price_"<?php echo $i ?>>
<td><input type="text" name = "quantity_<?php echo $i ?>"
id = "quantity_"<?php echo $i ?>>
<td><input type="text" name = "total_<?php echo $i ?>"
id = "total_"<?php echo $i ?>>
</td>
</tr>
<?php }?>
i am doing this in Controller
for ($i = 0; $i < 5; $i++) {
$data3 = array(
'item_id' => $this->input->post('item_id'),
'price' => $this->input->post('price_'.$i),
'quantity' => $this->input->post('quantity_'$i),
// etc
);
}
$this->load->model('salesModel');
$this->salesModel->addSoldItemtoDB($data3);
for
loop, otherwise you are only updating last item – charlietfl Jan 20 '13 at 15:34for
and update db withinfor
...not complicated – charlietfl Jan 20 '13 at 15:45