简体   繁体   中英

how i save the data into database that has been created using fetch

在此处输入图片说明

This is first picture

[![这是第三张图片,我已经做了一些计算。 ] 3

This is a second picture when i click the dropdown list it fetch the item and display like a table format. This is a third picture in this i have done some calculation..

My problem is how to save that table into database because this table has been created in model page...

public function Op_insert($data){

      $count = count($data['name']);

    for($i = 0; $i<$count; $i++){ 

$data[] =  array(

        'Stock' =>$data['Stock'][$i],
        'Rate'=>$data['Rate'][$i],
        'Amount' =>$data['Value'][$i]

      );
   }
     $this->db->insert_batch('opstock', $data); 
     }

this is model code..

I think problem with your variable name, you are using same variable for save new data that is $data rename with "$new_data"

public function Op_insert($data){

    $count = count($data['name']);

    for($i = 0; $i<$count; $i++){ 

        $new_data[] =  array(
            'Stock' =>$data['Stock'][$i],
            'Rate'=>$data['Rate'][$i],
            'Amount' =>$data['Value'][$i]
          );
    }
    $this->db->insert_batch('opstock', $new_data); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM