php如何实现全路径无限分类导航(代码)

来源:不言 发布时间:2018-10-10 16:00:23 阅读量:611

本篇文章给大家带来的内容是关于php如何实现全路径无限分类导航(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<?php

 

/**

 * @param php全路径无限分类

 */

 

include('db.inc.php');

function getPathCate($cateid){

    $sql = "select * ,concat(path,',',id) fullpath from likecate where id = $cateid";

    $res = mysql_query($sql);

    $row = mysql_fetch_assoc($res);

    $ids = $row['fullpath'];

    $sql = "select * from likecate where id in ($ids) orders by id asc";

    $res = mysql_query($sql);

    $result = array();

    while ($row = mysql_fetch_assoc($res)) {

        $result[] = $row;

    }

    return $result;

}

 

function displayPath($cateid,$link='cate.php?cid='){

    $res = getPathCate($cateid);

    $str = '';

    foreach ($res as $key => $value) {

        $str .= "<a href ='{$link}{$value['id']}'>{$value['catename']}</a>";

    }

 

}

 

echo displayPath(4,'cate.php?p=1&cid=');

以上就是php如何实现全路径无限分类导航(代码)的详细内容,更多请关注php中文网其它相关文章!


标签: PHP
分享:
评论:
你还没有登录,请先