0
쿼리 결과스토어 쿼리 결과
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
나는 객체의 배열 인 배열 [ '재고'] 모든 것을 표시 할.
나는 이것을했습니다 foreach ($ arr [ 'inventory'] $ invent) : echo $ invent [ 'ingredientID'];
하지만 foreach 부분에 오류가 있습니다. 오류 : foreach()에 잘못된 인수가 제공되었습니다.
어떻게해야합니까? endforeach;
경우'$의 arr'가 정의되어 인쇄를 사용해야합니까? 나는 foreach를 어디서나 볼 수 없다. – Leri
$ arr이 객체 배열을 포함하는 배열이라고 가정하면 – Jetoox
내가 말할 수있는 것은'$ arr [ 'inventory']'는 배열이 아닙니다. 'var_dump' 해보기 – Leri