I have a sql table like this:
id a b c1 c2 c3 d
1 x y z1 z2 z3 w
....
I want the following json output
{
"data": {
"id": "1",
"a": "x",
"b": "y",
"c": {
"c1": "z1",
"c2": "z2",
"c3": "z4"
},
"d": "w"
}
}
How should the mysqli query be for this case? What should be the array format and looping be to convert the query result into the required json?
For a new row, it would be added to data. So it would become "data": {data_of_row1, data_of_row2}