Mysql
 sql >> Datenbank >  >> RDS >> Mysql

fügen Sie mehrere Zeilen mit einem forigenk-Wert in Form ein

public function create() {
if($_POST) {
    $project_id   = $this->input->post('project');
    $staff_id     = $this->input->post('staff_id');
    $description  = $this->input->post('work_item_description');
    $qty          = $this->input->post('quantity');
    $unit         = $this->input->post('unit');
    $rate         = $this->input->post('rate');
    $laboure_hrs  = $this->input->post('laboure_hrs');
    $laboure_cost = $this->input->post('laboure_cost');
    $amount       = $this->input->post('txtmultTotal');
    $data         = array();

    $item_no      = $this->input->post('work_product_id');
    foreach($item_no as $key => $value) {
        $data[$key]       = array(
            'project_id'  => $project_id,
            'staff_id'    => $staff_id[$key],
            'item_no'     => $value,
            'description' => $description[$key],
            'qty'         => $qty[$key],
            'unit'        => $unit[$key],
            'rate'        => $rate[$key],
            'laboure_hrs' => $laboure_hrs[$key],
            'laboure_cost'=> $laboure_cost[$key],
            'amount'      => $amount[$key],
        );
    }
    $this->boq_model->create($data);
}

}