Separate content from Response Content

Yes and this is the result:

{
   "bus":[
      {
         "Bus_Plate_Number":"30",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Arnel Ignacio",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      }
   ]
}{
   "bus":[
      {
         "Bus_Plate_Number":"30",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Arnel Ignacio",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      },
      {
         "Bus_Plate_Number":"35",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Efren Catalan",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      }
   ]
}

This is not a valid json

2 Likes

you need to make some changes in your php code for generating valid json.

1 Like

I already warned you about thisā€¦
Iā€™ve already shown you the topic about JSONā€¦
Showed the link to test JSONā€¦

But it seems that the users here on the forum want to solve it in a few minutesā€¦

4 Likes

Sorry, the app that Iā€™m generating right now is part of my thesis thatā€™s why Iā€™m really eager to solve the problem quickly. Iā€™m currently adjusting the php file right now. This JSON is really new to me thatā€™s why I always got this error since last week.

(post deleted)

Already Rogerio shared a site . Please make use of it and correct your json

What he needs is to adjust the php script that generates the JSON.

2 Likes

I already knew whatā€™s the valid json. The only problem is how I will correct it through php. This is my code:

$conn = new mysqli($host,$username,$password,$dbname);
$data = mysqli_query($conn, "SELECT * FROM bus WHERE Bus_Dep_Time='9:30 AM' AND Bus_Branch='Calbayog'");
$array = array();
while ($result=mysqli_fetch_assoc($data))
{
    $array['bus'][]=$result;
    echo json_encode($array);
}

I keep adjusting the $array[ā€˜busā€™]=$result; but I always got the wrong json

I got it, i got itā€¦

:point_down:

From search in GOOGLE ā€¦

1 Like

It made some change. try it

$conn = new mysqli($host,$username,$password,$dbname);
$data = mysqli_query($conn, "SELECT * FROM bus WHERE Bus_Dep_Time='9:30 AM' AND Bus_Branch='Calbayog'");
$array = array();
while ($result=mysqli_fetch_assoc($data))
{
    $array[]['bus'][]=$result;
}
echo json_encode($array);
3 Likes

omg you got it! :scream:

1 Like

:point_down:
https://www.w3schools.com/PHP/php_looping_while.asp

1 Like

Iā€™m still adjusting my blocks, I canā€™t still separate the 2 records. :sweat_smile:

1 Like

I have this error:

I got that error from these blocks I guess:


1 Like

Hello, I finally separated the 2 records from response content, the only problem is that it only produces 1 record not 2. This is the result:

then this are my current blocks:

can you please check it and tell me whatā€™s wrong? :sweat_smile:

1 Like

Share your AIA @Gelo_Reuben

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.