Survey Apps from MYSQL using JSON

I think you haven’t understood the logic of the tutorial haha

Why do you put as a dictionary q1 and q2 ? if those variables are empty?

first of all, i have change survey back to pertanyaan, and like i mentioned before no result without an error

secondly, i put global q1 and q2 just for test, actually i have q1-q20,
and i have 10 row data like i giving ss before

its just empty for data 1-3, but on data 4-10 the q1 and q2 is available.
thats why im askign too, if i got empty for the first data, does that make all other data empty too even the data is exist on data 4-10.

sorry there is no explaintation about empty data work or not

But in your Mysql table the column q1, in row 1 2 and 3 has no data, so you do not receive it, because there is no data …

1 Like

yes thats is, so the dictionary cant get the rest data when there empty string right?

i make that for this scenario
1-3 input without an option q1-till rest

and for 1-4 input with an option from q1-till rest
i want to make a survey apps so bad :sob:

You can explain what each field in your table is. I think it will be necessary to redesign your table.

Surveys have one or more questions.
Questions have 1 or N answer options.
Surveys have 1 or N respondents.

Surveys have dates.
Surveys have an identifier name.
Surveys has an area.
All of the above items can be represented by fields in a table.

well, i think so.
i will change the structure to id, question, option ( storing text a,b,c,d,e not use q1 q2 q3), but still for data 1-3 without an data or empty just for indexing the question

my table is for storing an question with some option
id as pk
pertanyaan as question
q1… qn as an option, but for q1-q3 on data 1-3 as self input without an option,
id 1 is name, id 2 is adress, id 3 is phone

Continuing :
Questions belong to 1 or N surveys.
Answer options belong to 1 or N Questions.

both, i have 20 questions, with different options

Yes.
But you shouldn’t think about creating a static database. You have 20 questions, but you can have 200,000, so I’m showing you the way.

Surveys have 1 or N Questions.

Questions have 1 or N answer Options.

Questions belong to 1 or N Surveys.

Answer Options belong to 1 or N Questions.

Surveys have 1 or N Respondents.

So write block manually and store the answers only on database better than make a question with an option on database?

I didn’t write that. I’m telling you that: if you are creating a database, you have to design it efficiently and correctly. So I am writing 1 or N where N is an indeterminate and variable number (not static like 20). Databases must be designed so that a website, executable or app can use it in the best possible way.

Surveys have 1 or N Questions.

Questions have 1 or N answer Options.

Questions belong to 1 or N Surveys
(This gives your database flexibility. The same question can be used in several surveys)

Answer Options belong to 1 or N Questions
( Also Here )

Surveys have 1 or N Respondents.

1 Like

Yes ill change the structure like i say before maybe

Tbl_question
Id question option

Tbl_answer
Id answer id_quest
Is it good? Or not?
Ill try use the dictionary when got good new structure then tommorow, let me know if need more improvement
Thank you anyway for giving an advice

That way, And if you want to create new surveys? How will you do it?
Think about it.

You don’t need to answer now.

@pepocero @Rogerio_Rios

i have improve to this one but still nothing, its my card view?

this is my database
image
this is my json preview with redirect url


this is my block with my view

Hey do u have the json tool extension use it… it’s very easy to make with the extension i already have make a wallpaper app using php and json data :wink:

any documentation for it ?
or example ais maybe?

Here is the extension link

ok thanks,i try this one but the next button seems going wrong too because my json
when i do it got 1/-1
my php
<?php
include “koneksi.php”;
// $id = $_GET[‘id’] WHERE id=’$id’;
$sql = “SELECT * FROM kuesioner”;
$result = mysqli_query($koneksi,$sql);
$json_array= array();
while($row = mysqli_fetch_assoc($result))
{
$json_array=$row;
}
echo json_encode($json_array);
?>
my json
[{
“id”: “1”,
“question”: “Nama Responden”,
“option”: “1”
}, {
“id”: “2”,
“question”: “Alamat Lengkap”,
“option”: “1”
},…

Is its working if u just open it in web browser? The json data loaded or not? I think u r doing wrong that’s why u get the error…can u provide ur sample aia file with url i will check

yes my json loaded on redirect url
this is my aiayoibukan.aia (120.6 KB)