i would like to format it this way but i am unable to at the moment it looks like this:
{"success":true,"user":"tom","gender":"male","age":"2"}
{"success":true,"user":"anna","gender":"female","age":"3"}
but it should look like this
{
"result":[
{"success":true,"user":"tom","gender":"male"},
{"success":true,"user":"anna","gender":"female"}
]
}
this is my code
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$user= $row["user"];
$gender= $row["gender"];
$response["user"] = $user;
$response["gender"] = $gender;
$response["success"] = true;
echo json_encode($response);
}
}