可能重复:
Turn database result into array如何获得从数据库表的分层结构的PHP,在PHP数组,或JSON
嗨,大家好,你能帮帮我。如何从一个数据库表中的分层PHP结构,在PHP数组,或JSON,但有以下格式:
[
{
"attributes":{
"id":"111"
},
"data":"Some node title",
"children":[
{
"attributes":{
"id":"555"
},
"data":"A sub node title here"
}
],
"state":"open"
},
{
"attributes":{
"id":"222"
},
"data":"Other main node",
"children":[
{
"attributes":{
"id":"666"
},
"data":"Another sub node"
}
],
"state":"open"
}
]
我的SQL表包含的字段:ID,父,秩序,TITLE
你能帮我解决这个问题吗?我疯了试图得到这个。
非常感谢提前。 丹尼尔
可能重复[打开数据库导致进入阵列(http://stackoverflow.com/questions/2794638/turn-database-result-into-array) – 2010-05-09 23:29:41