0

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 than 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 don't know how to I take their parameters in a 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>&nbsp; <?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);
4

0 回答 0