mysql - Retrieve the Data in Tree structure in php -


currently working on creating apis in symfony2.2 framework.

i have retrieve bunch of questions , answers database.

                               q1                               /  \                              a1   a2                             /       \                            q2        q3                           / | \     / | | \                          a3 a4 a5  a6 a7 a8 a9                          /   |                        q4   q2  ... 

my db structure follows:

question: (questionid,questiontext) answeroption: (id,questionid,option,nextquestionid) 

here in above diagram there 1 root question has 2 choices a1 , a2.

on select of a1 user must redirected q2 , on , forth.

note : user may not answer questions.

now need find best way to:

1: retrieve data database.

2: format questions in json file.

ok. first take key database a1, , a2 stored, retrive data different table based upon selection,just match id's (selected a1 , a2) , retrive datas matchs selection id , on forth.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -