Mysql
 sql >> Base de données >  >> RDS >> Mysql

insérer plusieurs lignes en utilisant une valeur forigenk dans le formulaire

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);
}

}