i have two mysql tables
1. questions
2. answers
the question table has question and answer table has related answers each answer point to a question so it has levels
ex
question 1 -> answer 1 -> question 2
-> answer 2 -> question 3
-> answer 3 -> question 4 -> answer 1 -> question 5
-> answer 2 -> question 6
-> answer 3 -> question 7
question 8 -> answer 1 -> question 9
-> answer 2 -> question 10-> answer 1 ->question 12
answer 2 ->question 13
-> answer 3 -> question 11
i need to show questions as tree view
ex
question 1->question2
question3
question4->question 5
question 6
question 7
question 8->question 9
question 10->question 12
question 13
question 11
my question table fields are
id qtype qtext
my answeres table fields are
id answer quzid targetquz
Anyone know how to create a treeview using php based on this two tables. thank you very much.
Hope I'm not misunderstanding things here (not sure if you have intentionally question pointing to answer then to another question without any answer); but generally speaking I would use while
loop.
while()
{ first level here
while()
{ second level here
while()
{ third level here
....
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.