So this is my code, fetching the result of the query i need
$json_array = array();
$sql = "call rep_info();";
$result = $connect->query($sql);
while ($row = $result->fetch_assoc()) {
$json_array[] = $row;
}
mysqli_free_result($result);
mysqli_next_result($connect);
// Buat info user
$json_array2 = array();
$sql = "call rep_user();";
$result = $connect->query($sql);
while ($row = $result->fetch_assoc()) {
$json_array2[]["user"] = $row;
}
Then i merged the two arrays into one like this
$timeline = array_merge($json_array[0],$json_array2[0]);
$timeline2 = array_merge($json_array[1],$json_array2[1]);
$timeline = array_merge($timeline,$timeline2);
Encoded the merged array as well as echoing the variable
$encoded = json_encode($timeline);
echo $encoded;
So basically what i want is displaying 2 rows of the query result which is from json_array[0] and json_array[1]. But i only get 1 row in the echo result which the json_array[1] and json_array2[1].
What is the problem in this code? Thanks!
EDIT:
print_r($json_array[0]);
print_r($json_array2[0]);
Array
(
[id] => 11087
[message] => Late post.
Darmo ramai lancar
[latitude] => -7.292500019073486
[longitude] => 112.7388916015625
[image] => 1529894809620.jpeg
[thumb] =>
[sub_category] =>
[is_need_respond] => 0
[is_sticky] => 0
[is_hidden] => 0
[viewed] => 18
[deleted_at] =>
[created_at] => 2018-06-25 02:48:04
)
Array
(
[user] => Array
(
[id] => 621
[name] => asd
[username] => asd
[verified] => 2
[avatar] => icfab.jpg
[level] => 10
)
)