[英]PHP Create a Tree view using two tables
i have two mysql tables 我有两个mysql表
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. 任何人都知道如何基于这两个表使用php创建treeview。 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
循环。
while()
{ first level here
while()
{ second level here
while()
{ third level here
....
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.