Home > Backend Development > PHP Tutorial > php怎么实现如csdn论坛旁边目录树

php怎么实现如csdn论坛旁边目录树

WBOY
Release: 2016-06-23 13:02:47
Original
1056 people have browsed it


连接数据库后,将表里的数据放到$row中

CREATE TABLE `list` (`Id` int(30) unsigned NOT NULL AUTO_INCREMENT,`father_Id` int(30) unsigned DEFAULT '0',`Name` varchar(100) NOT NULL,`thing` varchar(500) DEFAULT NULL,PRIMARY KEY (`cate_Id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=34 ;
Copy after login

INSERT INTO `list` (`Id`, `father_Id`, `Name`, `thing`) VALUES(1, 0, '编程', '语言',),(2, 0, '网络', '知识'),(3, 1, 'php', '动态'),(4, 0, '生活', '兴趣');
Copy after login

写好数据库连接后,我用mysql_fetch_array()将数据放到数组$row中,接下来怎么将数组遍历显示成树形?小白一个,能具体教下吗,谢谢!!!


回复讨论(解决方案)

右键查看源码,可以看到它是这么个写法:

  


    

      
移动开发

      

        iOS
        Android
        Qt
        WP
      

    

    

      
云计算

      

        IaaS
        Pass/SaaS
        分布式计算/Hadoop
      

    

    


dl、dt、dd都是列表的html,参考http://www.w3school.com.cn/tags/tag_dd.asp
至于显示成csdn这样就要用到css和js了。

ztree....

2楼所说的是静态,我要实现的是读取数据库显示,,右击源码是被处理过的代码
3楼我查网上也是说ztree,可不懂

我自己解决了。思路大概是:
1.将数据库数据读取存放到一个数组里;
2.将数据转化为一个树型状的数组,实现子数组找到父数组;
3.将树型状的数组转为html代码;
4.添加css进行美化。
感谢你们的回帖。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template