N 层树 PHP MYSQL 帮助
我一直在研究 N 级树类。
任何人都可以建议我显示结果的最佳方式,即结果集的循环,我应该使用 DIV 还是 UL?
如果您发现文章太长而无法阅读,示例结果集将如下所示
Array ( [531] => stdClass Object ( [id] => 531 [rid] => 0 [created] => 1255384549 [nleft] => 1 [nright] => 8 [nlevel] => 1 ) [534] => stdClass Object ( [id] => 534 [rid] => 531 [created] => 1255384549 [nleft] => 2 [nright] => 3 [nlevel] => 2 ) [532] => stdClass Object ( [id] => 532 [rid] => 531 [created] => 1255384587 [nleft] => 4 [nright] => 7 [nlevel] => 2 ) [533] => stdClass Object ( [id] => 533 [rid] => 532 [created] => 1255384628 [nleft] => 5 [nright] => 6 [nlevel] => 3 ) )
感谢任何建议
谢谢
I have been looking at a N-level tree class.
Could anyone possibly advise on the best way I could display the results ie, the looping of the result set, should I use DIVs or ULs?
An example result set will look like so if you find the article too long to read
Array ( [531] => stdClass Object ( [id] => 531 [rid] => 0 [created] => 1255384549 [nleft] => 1 [nright] => 8 [nlevel] => 1 ) [534] => stdClass Object ( [id] => 534 [rid] => 531 [created] => 1255384549 [nleft] => 2 [nright] => 3 [nlevel] => 2 ) [532] => stdClass Object ( [id] => 532 [rid] => 531 [created] => 1255384587 [nleft] => 4 [nright] => 7 [nlevel] => 2 ) [533] => stdClass Object ( [id] => 533 [rid] => 532 [created] => 1255384628 [nleft] => 5 [nright] => 6 [nlevel] => 3 ) )
Any advice is apreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
找到了我正在寻找的解决方案。
现在进入格式化
Found the solution I was looking for.
Now onto the formatting
有点取决于您需要对输出做什么。我个人会使用未排序的列表或定义列表。
你想做什么?
Kinda depends on what you would need to do with the output. I would personally use unsorted lists or definition lists.
What are you trying to do?
将其输出为 UL 和 LI。如果输出太复杂,您可以在其顶部放置一个 JavaScript“树视图”组件 - 最好是可以自动将 UL 转换为树视图的组件。
Output it as ULs and LIs. If the output is too complex, you can put a JavaScript "Tree view" component on top of it - preferably one that can turn a UL into a tree view automatically.