I
I
Ivan Vasilich2019-01-20 01:14:45
SQL
Ivan Vasilich, 2019-01-20 01:14:45

How to output sql data to json?

Good afternoon or evening.
Please help me, I have a sqlite database that looks like this:

$categories = "CREATE TABLE IF NOT EXISTS Categories (
  cat_id INTEGER PRIMARY KEY,
  cat_name TEXT, 
  cat_score INTEGER)";

$questions = "CREATE TABLE IF NOT EXISTS Questions (
  question_id INTEGER PRIMARY KEY,
  question_body TEXT,
  question_picture TEXT,
  question_cat_id INTEGER,
  question_test_id INTEGER,
  question_number INTEGER,
  answer1 TEXT,
  answer2 TEXT,
  answer3 TEXT,
  correct_answer1 TEXT,
  correct_answer2 TEXT,
  correct_answer3 TEXT)";

i.e. there are N number of tests in the category, tests have N number of questions, questions have 2 or 3 possible answers, as well as 2 or 3 correct answers that I will compare with the possible ones when checking. how to display all this in json so that you can read it in a javascript script when loading a test.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vasilich, 2019-01-20
@jcmax

in general, I decided that there is a sqlite browser program there is an export to json
and each table is saved in a separate file as an array.
in general, we load each file and work with arrays

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question