Home > Net >  how to pass data from one table to another table
how to pass data from one table to another table

Time:09-01

I'm learning to make a simple website I'm having trouble in the section where I have a table called "process unit" where the table is joined with another table table, and I want to insert that table into another table named "process unit" how to pass from the process unit table to the process unit with the data the same but there is an addition in the field, thank you all forms of help are neededenter image description here

CodePudding user response:

sorry if my question is not clear, I will explain in detail here, I want to take data from a table named 'process' and move the contents of everything into a new table named 'status' with the same contents but there is additional data that I want to input - below is a sample code for the controller in codeigniter 3

public function simpan()
{
    if ($this->input->is_ajax_request() == true) {
        $status_invoice = $this->input->post('status_invoice', true);
        $id_customer = $this->input->post('id_customer', true);
        $id_user = $this->input->post('id_user', true);
        $status_tanggal = $this->input->post('status_tanggal', true);
        $status_typedevice = $this->input->post('status_typedevice', true);
        $status_namabarang = $this->input->post('status_namabarang', true);
        $status_imei = $this->input->post('status_imei', true);
        $status_kelengkapan = $this->input->post('status_kelengkapan', true);
        $status_diagnosa = $this->input->post('status_diagnosa', true);
        $status_biaya = $this->input->post('status_biaya', true);
        $status_uangmuka = $this->input->post('status_uangmuka', true);
        $kondisi = $this->input->post('kondisi', true);
        $id_jasa = $this->input->post('id_jasa', true);
        $teknisi = $this->input->post('teknisi', true);
        $catatan = $this->input->post('catatan', true);


        $this->M_Status->simpan(
            $status_invoice,
            $id_user,
            $id_customer,
            $status_tanggal,
            $status_typedevice,
            $status_namabarang,
            $status_imei,
            $status_kelengkapan,
            $status_diagnosa,
            $status_biaya,
            $status_uangmuka,
            $kondisi,
            $id_jasa,
            $teknisi,
            $catatan,
        );

        $msg = [
            'sukses' => 'Data Berhasil di Pindahkan ke Status Service!'
        ];

        echo json_encode($msg);
    }

and this is the code inside the model

public function simpan(
    $status_invoice,
    $id_user,
    $id_customer,
    $status_tanggal,
    $status_typedevice,
    $status_namabarang,
    $status_imei,
    $status_kelengkapan,
    $status_diagnosa,
    $status_biaya,
    $status_uangmuka,
    $kondisi,
    $id_jasa,
    $teknisi,
    $catatan,
) {
    $data = [
        'status_invoice' => $status_invoice,
        'id_user' => $id_user,
        'id_customer' => $id_customer,
        'status_tanggal' => $status_tanggal,
        'status_typedevice' => $status_typedevice,
        'status_namabarang' => $status_namabarang,
        'status_imei' => $status_imei,
        'status_kelengkapan' => $status_kelengkapan,
        'status_diagnosa' => $status_diagnosa,
        'status_biaya' => $status_biaya,
        'status_uangmuka' => $status_uangmuka,
        'kondisi' => $kondisi,
        'id_jasa' => $id_jasa,
        'teknisi' => $teknisi,
        'catatan' => $catatan,
    ];
    $this->db->insert('status', $data);
}

it seems that here I can't apply it and instead destroy it, the data can't be entered into the new table and the data in the old table is also not deleted

this is a photo on the process table

and this is the photo on the status table

CodePudding user response:

yes, I have done it and have done a join between tables but the problem is, the data I input does not enter the 'status' table and for the old table it is not deleted, I don't want 2 data to accumulate together

  • Related