i make 2 queries , i'd add rows query 2 query 1. also, suppose getresult1() returns no column called "item2"
$result1 = getresult1(); $result2 = getresult2(); foreach ($result2 $res) { $data = array(); $data['item1'] = $res->item1; $data['item2'] = $res->item2; $result1[] = $data; }
there error here on line
$result1[] = $data
and reads
fatal error: cannot use object of type mysqli_result array
i think happening, i'm not quite sure how fix it. rows getting converted json, , can that array of arrays.
i've fixed problem converting $result1 array of arrays. using while loop , fetch_array() call, there quick way convert $result1 array of arrays instead of record set?
or can use different syntax on problem line?
the problem result1
variable not array, it's object, cannot set data using arrayaccess []
, can following:
$result1 = getresult1(); $result2 = getresult2(); foreach ($result2 $res) { $result2->item1 = $result1->item1; $result2->item2 = $result1->item2; }
Comments
Post a Comment