I get the information from the database. For example, my database data is as follows: I get the information from the database. For example, my database data is as follows:
-------------------------------------------------
p_id | description_name | description_value |
-------------------------------------------------
1 | author | X1 |
-------------------------------------------------
1 | editor | X2 |
-------------------------------------------------
2 | author | Y1 |
-------------------------------------------------
3 | author | Z1 |
-------------------------------------------------
3 | editor | Z2 |
------------------------------------------------- ...
So in the php code section I use this method to get descriptions
:
<?php
...
$result5 = mysqli_query($conn,"SELECT * FROM `descriptions` ");
while ($row5 = $result5 ->fetch_assoc()){
$des[] = [(int) $row5['p_id'] ,[ $row5['description_name'] => $row5['description_value']] ] ;
}
echo json_encode( $des);
?>
this is the output of this code:
[[1,{"author": "X1"}],[1,{"editor": "X2"}],[2,{"author": "Y1"}],[3,{"author": "Z1"}],[3,{"editor": "Z2"}],[ ...
But, my expected output is, like this:
[{"p_id" : 1,"author": "X1","editor": "X2"},{"p_id" : 2, "author": "Y1"},{"p_id" : 3,"author": "Z1","editor": "Z2"},{...
I hope that with your guidance this problem will be solved for me, Thank You...