@maumar it should be this way since you said you are using Dynamic Table Row.
foreach($allmodeldata as $loopdata){
$db->where("wh_item", $loopdata['product']);
$db->where("category", $loopdata['category']);
$wh_quantity[] = $db->getValue("whstock", "wh_quantity");
}
And this one for after adding records
for($i=0; $i<count($allmodeldata); $i++){
$table_data = array(
"wh_quantity" => $wh_quantity[$i] + $allmodeldata[$i]['qty']
);
$db->where("wh_item", $allmodeldata[$i]['product']);
$db->where("category", $allmodeldata[$i]['category']);
$db->update("whstock", $table_data);
}
Enjoy .