0
votes

I am making an application in codeigniter using php.I want to insert data into database table where the data is entered in an input box inside a loop.I have tried the below code so far:

cms_model.php

public function loadadd($mekhala_Id){
    
        $query = $this->db->get_where('tb_unit', array('mandalam_Id' => $mekhala_Id));
        echo  form_open('Payment/amount'); 
    ?>


<h1>Members List</h1>
        <table border="1">
            <tr>
                 <th>Unit</th>
                  <th>Unit Secretary</th>
                 <th>Amount paid</th>
                 
            </tr>
            <?php
    foreach ($query->result() as $row)
    {
        ?>

            <tr>
                <td> <?php echo $row->unitName ;?></td>
                        <td> <?php echo $row->unit_sec ;?></td>
                       <td> <?php echo form_input(array('name'=>'na','placeholder'=>'Rupees Paid')) ;?></td>  
            </tr>
            <?php
       
}

 echo form_submit(array('name'=>'sub','value'=>'submit'));
        echo form_close();
}



 public function loadpayment($paid){
 
   //  $paid= $this->input->post('na');

           $fieldsData = $this->db->field_data('tb_unit');
           $datacc = array(); // you were setting this to a string to start with, which is bad

     foreach ($fieldsData as $key => $field)
{
    $datacc[ $field->Amount] = $this->input->post( $field->Amount);
}
$this->db->insert('tb_unit', $datacc);

}
   //  $this->db->set('Amount', $paid)



  
}



        
?> 
   

I have encountered below error while running this code:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$Amount

Filename: models/cms_model.php

Line Number: 110

Please help me to resolve this error.

1
Any one please help me to find answer.php

1 Answers

0
votes

change line #110 to:

$datacc[$field->name] = $this->input->post($field->name);