This question already has an answer here:
Extracting Values from Nested JSON Data !
$response = array();
$result = mysqli_query($conn, "
SELECT id, GROUP_CONCAT(CONCAT_WS(':', Name) SEPARATOR ',') AS Result
FROM mytbl GROUP BY id
");
mysqli_num_rows($result);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$char = array("id"=>$row["id"], "char"=>[$row["Result"]]);
array_push($response,array('Attr'=>$char));
}
}
echo json_encode($response);
i added photo for what i need
</div>