Survey Apps from MYSQL using JSON

I want to make a survey apps that taking the question from mysql using JSON
this is the result of json_encoded from table question
[{“id”:“5”,“pertanyaan”:“Usia”,“q1”:"<21 tahun",“q2”:“26-40 tahun”,“q3”:">55 tahun":""}]
lets say i have table_result with attributes id and answer

and i want to make a textinput that storing the answer each question(pertanyaan).
so how to show the question with the textinput and store to other table??

i following the How to Create Quiz App with Mysql Database in Kodular || Hindi & Bangla - YouTube but this one make me confused because using old json. I use JSONTool1

Assuming that json is well formed , you can use Dictionary blocks to get data from JSON

See more info here

1 Like

thank by giving about dictionaries and how to use, but if i use the dictionaries to call the json, how and where i put my textinput for storing the answer?

You will use the dictionary blocks to get the part you want inside your Json.

Json

Blocks

1 Like

i try this one but getting error, im not using an api, i call my json from database


this is my blocks

this is my result of json
image

its because i use an php to call it? or maybe i wrong to put some blocks?

Is your response in valid json format ? Save the response in a label, copy text and use an online json validator to check it

it seems i missed on implement the global when getting that error, i have change the blocks and coming new error
image
new blocks


this result from json prettier you tell

Most probably global survey is an empty list , debug your blocks with Do it and see if your global variables are populated ok

i try my global survey to the id number like 1, and getting bunch error empty string list
but i want to make a survey apps that having each question that have a differents sum of answer

You need to debug your blocks. Put some notifications showing the values ​​of your variables in various places in your blocks so that you can track where and what the values ​​of your variables are.


so something wrong with my json?
the error, Select list item: Attempt to get item number 1 of a list of length 0: ()
and the list cant accept argument lenght of list “not found”

that error is because the pertanyaan list is empty

image

The problem is that pertanyaan is inside the survey

In the block of the variable pertanyaan in the dictionary do not use pertanyaan, use survey

ah… so its because the json, but after change the block just like you say
there is no error, but no result too

put the variable survey on a label and show the result

@Mdruid_D
Did you try ,
What are we suggesting?

You do not get data because you are telling it to look for SURVEY inside SURVEY, which is not logical. There you have to write pertanyaan

yes i try it when there a new informastion or reply to my block and giving new updates on my post, and this is the result when i put a label

I suggested that you place it in several places in your blocks to keep track of the values ​​of the variables.
:thumbsup:

change and empty without an error

@Rogerio_Rios i try to get result of all my global

  1. pertanyaan with the data ->success print the data like Nama Responden, Alamat Lengkap, No hp etc
  2. q1 -> ()
  3. q2 -> ()
    so q1 and q2 giving all empy even there some of data with string, its because my q1 and q2 on id 1 is empty that make other data empty too?
    this is from table for json

all result view -> empty
no error message