The view must be like this:
{
"app": [
{
"system": {
"base_url": "https://youtube.com",
"email_address": "[email protected]",
"privacy_policy_url": "https://googles.com",
"terms_of_use_url": "https://fasfg.com",
"splash_screen_timout": 1000,
"loading_spinner": "Wave"
}
},
{
"settings": {
"dark_mode": true,
"screen_sleep": true,
"fullscreen_mode": true,
"notification_sound_option": true,
"notification_vibration_option": true,
"download_via_wifi": true,
"device_information": true,
"other_links": true,
"danger_zone": true
}
}
But when I try to make it like this it overwrites the old function and prints the last object like this:
{
"app": [
{
"settings": {
"dark_mode": true,
"screen_sleep": true,
"fullscreen_mode": true,
"notification_sound_option": true,
"notification_vibration_option": true,
"download_via_wifi": true,
"device_information": true,
"other_links": true,
"danger_zone": true
}
}
this is my PHP code i know the problem but I can't fix it, I think the answer is appending data but I don't know how and I searched for answer but nothing clear for me:
$fetch_system = $db->prepare("SELECT base_url, email_address,
privacy_policy_url, terms_of_use_url,
splash_screen_timout, loading_spinner
FROM configuration
WHERE secret_api_key=?");
$fetch_system->bind_param("s", $_SESSION['secret_api_key']);
$fetch_system->execute();
$rows = array();
$result = $fetch_system->get_result();
while($rows1 = $result->fetch_assoc()) {
$rows['app'] = $rows1;
}
$fetch_settings = $db->prepare("SELECT dark_mode, screen_sleep, full_screen,
notification_sound, notification_vibration,
download_via_wifi, device_information,
other_links, danger_zone
FROM configuration
WHERE secret_api_key=?");
$fetch_settings->bind_param("s", $_SESSION['secret_api_key']);
$fetch_settings->execute();
$rows['app'] = array();
$result = $fetch_settings->get_result();
while($rows2 = $result->fetch_assoc()) {
$rows['settings'] = $rows2;
}
echo json_encode($rows);
{}do not balance in your JSONs. And you have an unclose[.in each json. Please fix this so it is easier to understand.$rows['app'] = array();, you are clearing the values saved before.