查询结果
Array
(
[0] => stdClass Object
(
[ingredientID] => 2
[code] => Bf
[description] => 1st Class Flour
[volume] => 8268
[price] => 750
[amount_gram] => 0.02980
[status] => Inactive
[uom_id] => 1
[flour] => Yes
)
[1] => stdClass Object
(
[ingredientID] => 3
[code] => Sf
[description] => 3rd Class Flour
[volume] => 18490
[price] => 635
[amount_gram] => 0.02540
[status] => Inactive
[uom_id] => 5
[flour] => Yes
)
..........
我想将此结果作为行库存存储到另一个表中。该表将如下所示:
ID inventory
1 (the result)
2 (another result)
之后我会再次查询它,以便我可以显示结果。
这是我最近所做的。
店铺:
//getting the result
$inv = $this->db->get_from('table','id'=>'1')->row();
<input type="hidden" name="inventory" value="<?php print_r($inv)?>">
//storing in the new table
$this->db->insert('table2',array('inventory'=>$this->input->post('inventory')));
得到:
$inventory = $this->db->get_where('table2',array('ID'=>'1'))->row_array();
//result
array
(
[ID] => 1
[inventory] =>
array
(
[0] => stdClass Object
(
[ingredientID] => 2
...... and so on
我想显示数组 ['inventory'] 中的所有内容,它是一个对象数组。
我已经完成了这个 foreach($arr['inventory'] as $invent): echo $invent['ingredientID'];
但是 foreach 部分有错误。错误:为 foreach() 提供的参数无效
我应该怎么办?结束;