0

I want to insert script using CodeIgniter two table table1 and table2.
table1 insert one time date but table2 three times date using for loop but getting an error. Loop is not working, kindly provide some suggestions.

Thanks

Code:

public function add_rdi() {
    $user_id = $this -> input -> post('user_id');
    $user_rdi = $this -> input -> post('user_rdi');
    $zoneID = $this -> input -> post('zoneID');
    $mtstock6 = $this -> input -> post('mtstock6');
    $tfstank6 = $this -> input -> post('tfstank6');

    $data = [
        'user_id' => $user_id,
        'user_rdi' => $user_rdi,
        'zoneID' => $zoneID,
        'mtstock6' => $mtstock6,
        'tfstank6' => $tfstank6,
    ];

    $data1 = ['fuelstock' => $gtfb,
        'fuelrecrdi' => $gtfb,
        'stockrdiname' => $user_rdi,
        'vfstock' => $tfstank1,
        'vfstock' => $tfstank2,
        'vfstock' => $tfstank3,
        'hfstock' => $tfstank4,
        'hfstock' => $tfstank5,
        'hfstock' => $tfstank6,
        'user_id' => $user_id

    ];

    $this -> load -> model('Mechanical_model_rdi');
    $query = $this -> db -> where('rdiname', $rdiname);
    $query = $this -> db -> get('fuel_rdi');
    if ($query -> num_rows() < 1) {
        $this -> Mechanical_model_rdi -> add_rdi($data);

        for ($i = 1; $i <= 3; $i++) {
            $this -> Mechanical_model_rdi -> add_rdi($data1);
        }

    } $this -> load -> view('mechanical/Mechanical_add_rdi');
}
3
  • what is error ? , Check your log file . Commented Dec 9, 2019 at 12:35
  • this questions has an already answered here - stackoverflow.com/questions/47727051/… Commented Dec 9, 2019 at 12:44
  • please share the error screen Commented Dec 9, 2019 at 13:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.