1
votes
$ID = $this->input->post('barang');
$reslt = array();
foreach($ID AS $key => $val){
    $reslt[] = array(
    "id" => $ID[$key],
    "stok"  => $_POST['qty'][$key]);
}

$this->db->update_batch('barang', $reslt, 'id');

Error

A PHP Error was encountered Severity: Notice

Message: Undefined index: id

Filename: database/DB_query_builder.php

Line Number: 1955

Backtrace:

File: E:\xampp\htdocs\restly\application\controllers\admin.php Line: 343 Function: update_batch

File: E:\xampp\htdocs\restly\index.php Line: 315 Function: require_once

Can any body help me?

3
You have typo error here $_POST['qty'][$key]); Change this to $_POST['qty'][$key]) - ankit suthar

3 Answers

0
votes

You have added semicolon extra,just remove that. Updated code:

$reslt[] = array(
                    "id" => $ID[$key],
                    "stok"  => $_POST['qty'][$key])
}
0
votes

Try this code :

$ID = $this->input->post('barang');
    $reslt = array();
    for($x = 0; $x < sizeof($ID); $x++){
        {
            $reslt[] = array(
                        "id" => $ID[$x],
                        "stok"  => $_POST['qty'][$x]
                        );
        }
    $this->db->update_batch('barang', $reslt, 'id');

Update this code into your code ..and check it and accept if it works!

0
votes

You have typo error here

$_POST['qty'][$key]);

Change this to

$_POST['qty'][$key])

Your Final foreach should be:

foreach($ID AS $key => $val){
$reslt[] = array(
    "id"    => $ID[$key],
    "stok"  => $_POST['qty'][$key])
}